From 68d759261053dc62682d7b6df75cc89ce3cbbc4d Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Sun, 27 Mar 2022 06:58:10 +0200 Subject: [PATCH] Fixes #4008 - KB Public menus scroll bar positioning incorrect --- .../controllers/_manage/knowledge_base.coffee | 22 +++++---- .../knowledge_base/public_menu_manager.coffee | 2 +- .../app/views/knowledge_base/base_form.coffee | 4 +- .../app/views/knowledge_base/delete.coffee | 2 +- ...new_modal.coffee => new_controller.coffee} | 45 ++++++++++--------- i18n/zammad.pot | 8 +--- 6 files changed, 42 insertions(+), 41 deletions(-) rename app/assets/javascripts/app/views/knowledge_base/{new_modal.coffee => new_controller.coffee} (55%) diff --git a/app/assets/javascripts/app/controllers/_manage/knowledge_base.coffee b/app/assets/javascripts/app/controllers/_manage/knowledge_base.coffee index a040778ef..8c99508c5 100644 --- a/app/assets/javascripts/app/controllers/_manage/knowledge_base.coffee +++ b/app/assets/javascripts/app/controllers/_manage/knowledge_base.coffee @@ -49,9 +49,6 @@ class App.ManageKnowledgeBase extends App.ControllerTabs App.KnowledgeBase.find(@knowledge_base_id).remove(clear: true) @fetchAndRender() - release: -> - @modal?.el.remove() - processLoaded: -> if @knowledge_base_id @renderLoaded() @@ -59,13 +56,18 @@ class App.ManageKnowledgeBase extends App.ControllerTabs @renderNonExistant() renderNonExistant: -> - @renderScreenError(detail: __('There is no Knowledge Base yet. Please create one.'), el: @$('.page-content')) - @headerSwitchInput.prop('checked', false) + @headerSwitchInput.attr('disabled', true) - @modal = new App.KnowledgeBaseNewModal( - parentVC: @ - container: @el.closest('.main') - ) + @tabs =[ + { + name: __('Theme') + target: 'style' + controller: App.KnowledgeBaseNewController + params: { parentVC: @ } + } + ] + + @render() didChangeHeaderSwitch: -> @headerSwitchInput.prop('disabled', true) @@ -89,6 +91,8 @@ class App.ManageKnowledgeBase extends App.ControllerTabs ) renderLoaded: -> + @headerSwitchInput.attr('disabled', false) + params = { knowledge_base_id: @knowledge_base_id parentVC: @ diff --git a/app/assets/javascripts/app/controllers/knowledge_base/public_menu_manager.coffee b/app/assets/javascripts/app/controllers/knowledge_base/public_menu_manager.coffee index ecb96e103..5388ff30b 100644 --- a/app/assets/javascripts/app/controllers/knowledge_base/public_menu_manager.coffee +++ b/app/assets/javascripts/app/controllers/knowledge_base/public_menu_manager.coffee @@ -47,5 +47,5 @@ class App.KnowledgeBasePublicMenuManager extends App.Controller new App.KnowledgeBasePublicMenuForm( location: location, knowledge_base_id: @knowledge_base_id - container: @el.closest('.main') + container: @el.closest('.content') ) diff --git a/app/assets/javascripts/app/views/knowledge_base/base_form.coffee b/app/assets/javascripts/app/views/knowledge_base/base_form.coffee index 0a2b284b0..475748a2c 100644 --- a/app/assets/javascripts/app/views/knowledge_base/base_form.coffee +++ b/app/assets/javascripts/app/views/knowledge_base/base_form.coffee @@ -127,7 +127,7 @@ class App.KnowledgeBaseCustomAddressForm extends App.KnowledgeBaseForm button.disabled = false new App.KnowledgeBaseServerSnippet( - container: @el.closest('.main') + container: @el.closest('.content') snippets: data.snippets address: data.address address_type: data.address_type @@ -140,6 +140,6 @@ class App.KnowledgeBaseCustomAddressForm extends App.KnowledgeBaseForm new App.ControllerErrorModal( message: xhr.responseJSON.error - container: @el.closest('.main') + container: @el.closest('.content') ) ) diff --git a/app/assets/javascripts/app/views/knowledge_base/delete.coffee b/app/assets/javascripts/app/views/knowledge_base/delete.coffee index 415884d61..1502cb870 100644 --- a/app/assets/javascripts/app/views/knowledge_base/delete.coffee +++ b/app/assets/javascripts/app/views/knowledge_base/delete.coffee @@ -16,7 +16,7 @@ class App.KnowledgeBaseDelete extends App.KnowledgeBaseForm formController.hideAlert() loader = new App.ControllerModalLoading( - container: @parentVC.el + container: @parentVC.el.closest('.content') ) @ajax( diff --git a/app/assets/javascripts/app/views/knowledge_base/new_modal.coffee b/app/assets/javascripts/app/views/knowledge_base/new_controller.coffee similarity index 55% rename from app/assets/javascripts/app/views/knowledge_base/new_modal.coffee rename to app/assets/javascripts/app/views/knowledge_base/new_controller.coffee index 197928026..34ab51594 100644 --- a/app/assets/javascripts/app/views/knowledge_base/new_modal.coffee +++ b/app/assets/javascripts/app/views/knowledge_base/new_controller.coffee @@ -1,27 +1,28 @@ -class App.KnowledgeBaseNewModal extends App.ControllerModal - head: __('Create Knowledge Base') - screen: 'admin_create' - - buttonClose: false - buttonCancel: false - backdrop: 'static' - keyboard: false +class App.KnowledgeBaseNewController extends App.Controller + events: + 'submit form': 'submit' constructor: -> - @formController = new App.ControllerForm( - model: App.KnowledgeBase - params: @item - screen: @screen - autofocus: false - ) - super - content: -> - @formController.form + @render() + + render: -> + @formController = new App.ControllerForm( + model: App.KnowledgeBase + screen: 'admin_create' + autofocus: false + formClass: 'settings-entry' + fullForm: true + fullFormSubmitLabel: __('Create Knowledge Base') + fullFormButtonsContainerClass: 'justify-end' + fullFormSubmitAdditionalClasses: 'btn--success' + ) + + @el.html @formController.form prepareParams: (params) -> - for key, attribute of App.KnowledgeBase.attributesGet(@screen) + for key, attribute of App.KnowledgeBase.attributesGet(@formController.screen) dom = @$(".#{attribute.tag}[data-attribute-name=#{attribute.name}]") App.UiElement[attribute.tag].prepareParams?(attribute, dom, params) @@ -33,8 +34,10 @@ class App.KnowledgeBaseNewModal extends App.ControllerModal params['homepage_layout'] = 'grid' params['category_layout'] = 'grid' - onSubmit: (e) -> - params = @formParams(@el) + submit: (e) -> + @preventDefaultAndStopPropagation(e) + + params = @formParam(@el) @prepareParams(params) @applyDefaults(params) @@ -47,8 +50,6 @@ class App.KnowledgeBaseNewModal extends App.ControllerModal success: (data) => @parentVC.fetchAndRender() - @parentVC.modal = undefined - @close() error: (xhr) => @formEnable(@el) diff --git a/i18n/zammad.pot b/i18n/zammad.pot index 9e23962e2..d958edf49 100644 --- a/i18n/zammad.pot +++ b/i18n/zammad.pot @@ -2096,7 +2096,7 @@ msgstr "" msgid "Could not read raw logo!" msgstr "" -#: app/assets/javascripts/app/views/knowledge_base/new_modal.coffee +#: app/assets/javascripts/app/views/knowledge_base/new_controller.coffee msgid "Couldn't create Knowledge Base" msgstr "" @@ -2145,7 +2145,7 @@ msgstr "" msgid "Create Channels" msgstr "" -#: app/assets/javascripts/app/views/knowledge_base/new_modal.coffee +#: app/assets/javascripts/app/views/knowledge_base/new_controller.coffee msgid "Create Knowledge Base" msgstr "" @@ -9072,10 +9072,6 @@ msgstr "" msgid "There is existing content. Do you want to overwrite it?" msgstr "" -#: app/assets/javascripts/app/controllers/_manage/knowledge_base.coffee -msgid "There is no Knowledge Base yet. Please create one." -msgstr "" - #: app/assets/javascripts/app/views/channel/chat.jst.eco msgid "There is no agent online." msgstr ""