From 4676373b7aaf677fe1fd6a6860c727eafc21b79f Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Wed, 28 Apr 2021 12:53:29 -0300 Subject: [PATCH 1/2] feat (simple-page-task): loading icon listening for dhtml ready --- src/adonisjs/public/author/js/draft.js | 5 +++-- src/adonisjs/public/author/js/template-case.js | 1 + src/adonisjs/public/infra/simple-page-tasks.js | 14 ++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/adonisjs/public/author/js/draft.js b/src/adonisjs/public/author/js/draft.js index 62783013..37f63b79 100644 --- a/src/adonisjs/public/author/js/draft.js +++ b/src/adonisjs/public/author/js/draft.js @@ -83,15 +83,16 @@ class DraftManager { ) } } - MessageBus.int.publish('control/dhtml/ready') } - async _draftCategoryCasesSelect (advanced, topic, message) { + async _draftCategoryCasesSelect (topic, message) { const cl = document.getElementsByClassName('buttons-container') const caseListInput = document.querySelector('#table_id') if(message != null && message.id != null && message.id == 'harena-dhtml-cases'){ + + if(document.querySelector('#select-all-checkbox')){ const selectAllCases = document.querySelector('#select-all-checkbox') diff --git a/src/adonisjs/public/author/js/template-case.js b/src/adonisjs/public/author/js/template-case.js index f3235329..e685b33a 100644 --- a/src/adonisjs/public/author/js/template-case.js +++ b/src/adonisjs/public/author/js/template-case.js @@ -97,6 +97,7 @@ class TemplateToCase { }) .catch(function (error) { console.log(error) + window.location.href = '/author/?id=' + _caseId }) } } catch (e) { diff --git a/src/adonisjs/public/infra/simple-page-tasks.js b/src/adonisjs/public/infra/simple-page-tasks.js index 91b8684f..587f3302 100644 --- a/src/adonisjs/public/infra/simple-page-tasks.js +++ b/src/adonisjs/public/infra/simple-page-tasks.js @@ -1,6 +1,7 @@ class PageController { constructor () { var isPageReady = false + var dhtmlLoaded = false var hasremovedLoading = false PageController.scriptsComplete = false this.removeLoadingIcon = this.removeLoadingIcon.bind(this) @@ -22,9 +23,8 @@ class PageController { MessageBus.int.subscribe('control/html/ready', this.pageReady) } async pageReady(){ - + PageController.instance.paginationButtons(parseInt(new URL(document.location).searchParams.get('page') || 1)) if(!this.isPageReady){ - PageController.instance.paginationButtons(parseInt(new URL(document.location).searchParams.get('page') || 1)) // Verifies if the page contains the correct element if(document.querySelector('#filter-form')){ var filterElements = [] @@ -45,8 +45,14 @@ class PageController { } async removeLoadingIcon(){ - - if(!this.hasremovedLoading){ + var dhtmlList = document.querySelectorAll('dcc-dhtml') + this.dhtmlLoaded = true + for(var i in dhtmlList){ + if(dhtmlList[i]._ready == false){ + this.dhtmlLoaded = false + } + } + if(!this.hasremovedLoading || this.dhtmlLoaded){ if(document.querySelector('#loading-page-container')){ setTimeout(function(){ document.querySelector('main').classList.remove('invisible') From 44f550faa87d781a839a76b588a1fbca7f9605ae Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Wed, 28 Apr 2021 14:25:37 -0300 Subject: [PATCH 2/2] fix (simple-page-task): wrong condition --- src/adonisjs/public/infra/simple-page-tasks.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adonisjs/public/infra/simple-page-tasks.js b/src/adonisjs/public/infra/simple-page-tasks.js index 587f3302..019d649b 100644 --- a/src/adonisjs/public/infra/simple-page-tasks.js +++ b/src/adonisjs/public/infra/simple-page-tasks.js @@ -52,7 +52,7 @@ class PageController { this.dhtmlLoaded = false } } - if(!this.hasremovedLoading || this.dhtmlLoaded){ + if(!this.hasremovedLoading && this.dhtmlLoaded){ if(document.querySelector('#loading-page-container')){ setTimeout(function(){ document.querySelector('main').classList.remove('invisible') @@ -73,8 +73,9 @@ class PageController { PageController.instance.appropriateBreadcrumb() PageController.scriptsComplete = true // console.log(PageController.scriptsComplete) + this.hasremovedLoading = true + } - this.hasremovedLoading = true } controlDropdownMenu(){