Fixes #3924 - Add confirmation dialog on visibility change of an article or in article creation.
This commit is contained in:
parent
93932055dd
commit
fdccd3cafd
15 changed files with 209 additions and 36 deletions
|
@ -0,0 +1,15 @@
|
|||
class App.ControllerConfirm extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: __('Yes')
|
||||
buttonClass: 'btn--danger'
|
||||
head: __('Confirmation')
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
App.i18n.translateContent(@message)
|
||||
|
||||
onSubmit: =>
|
||||
@close()
|
||||
if @callback
|
||||
@callback()
|
|
@ -3,7 +3,7 @@ class App.ControllerGenericDestroyConfirm extends App.ControllerModal
|
|||
buttonCancel: true
|
||||
buttonSubmit: __('delete')
|
||||
buttonClass: 'btn--danger'
|
||||
head: __('Confirm')
|
||||
head: __('Confirmation')
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
|
@ -19,19 +19,3 @@ class App.ControllerGenericDestroyConfirm extends App.ControllerModal
|
|||
@log 'errors'
|
||||
@showAlert(data.human_error || data.error)
|
||||
@item.destroy(options)
|
||||
|
||||
class App.ControllerConfirm extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: __('yes')
|
||||
buttonClass: 'btn--danger'
|
||||
head: __('Confirm')
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
App.i18n.translateContent(@message)
|
||||
|
||||
onSubmit: =>
|
||||
@close()
|
||||
if @callback
|
||||
@callback()
|
|
@ -0,0 +1,3 @@
|
|||
class App.ControllerArticlePublicConfirm extends App.ControllerConfirm
|
||||
head: __('Publish Article')
|
||||
message: __('Do you really want to set the visibility of this article to "public"?')
|
|
@ -20,6 +20,21 @@ class Internal
|
|||
@perform: (articleContainer, type, ticket, article, ui) ->
|
||||
return true if type isnt 'internal' && type isnt 'public'
|
||||
|
||||
if type is 'public'
|
||||
if App.Config.get('ui_ticket_zoom_article_visibility_confirmation_dialog')
|
||||
new App.ControllerArticlePublicConfirm(
|
||||
callback: =>
|
||||
@change(articleContainer, article, ui)
|
||||
container: ui.el.closest('.content')
|
||||
)
|
||||
else
|
||||
@change(articleContainer, article, ui)
|
||||
else
|
||||
@change(articleContainer, article, ui)
|
||||
|
||||
true
|
||||
|
||||
@change: (articleContainer, article, ui) ->
|
||||
# storage update
|
||||
internal = true
|
||||
if article.internal == true
|
||||
|
@ -35,6 +50,5 @@ class Internal
|
|||
|
||||
ui.render()
|
||||
|
||||
true
|
||||
|
||||
App.Config.set('100-Internal', Internal, 'TicketZoomArticleAction')
|
||||
|
|
|
@ -328,6 +328,13 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
e.stopPropagation()
|
||||
if @articleNewEdit.hasClass('is-public')
|
||||
@setArticleInternal(true)
|
||||
else
|
||||
if App.Config.get('ui_ticket_zoom_article_visibility_confirmation_dialog')
|
||||
new App.ControllerArticlePublicConfirm(
|
||||
callback: =>
|
||||
@setArticleInternal(false)
|
||||
container: $(e.target).closest('.content')
|
||||
)
|
||||
else
|
||||
@setArticleInternal(false)
|
||||
|
||||
|
|
36
db/migrate/20220119102815_issue3924_confirmation_dialog.rb
Normal file
36
db/migrate/20220119102815_issue3924_confirmation_dialog.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class Issue3924ConfirmationDialog < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
|
||||
# return if it's a new setup
|
||||
return if !Setting.exists?(name: 'system_init_done')
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: __('Note - visibility confirmation dialog'),
|
||||
name: 'ui_ticket_zoom_article_visibility_confirmation_dialog',
|
||||
area: 'UI::TicketZoom',
|
||||
description: __('Defines if the agent has to accept a confirmation dialog when changing the article visibility to "public".'),
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'ui_ticket_zoom_article_visibility_confirmation_dialog',
|
||||
tag: 'boolean',
|
||||
options: {
|
||||
true => 'yes',
|
||||
false => 'no',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: false,
|
||||
preferences: {
|
||||
prio: 100,
|
||||
permission: ['admin.ui'],
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
end
|
||||
end
|
|
@ -702,6 +702,34 @@ Setting.create_if_not_exists(
|
|||
},
|
||||
frontend: true
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: __('Note - visibility confirmation dialog'),
|
||||
name: 'ui_ticket_zoom_article_visibility_confirmation_dialog',
|
||||
area: 'UI::TicketZoom',
|
||||
description: __('Defines if the agent has to accept a confirmation dialog when changing the article visibility to "public".'),
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'ui_ticket_zoom_article_visibility_confirmation_dialog',
|
||||
tag: 'boolean',
|
||||
options: {
|
||||
true => 'yes',
|
||||
false => 'no',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: false,
|
||||
preferences: {
|
||||
prio: 100,
|
||||
permission: ['admin.ui'],
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: __('Email - subject field'),
|
||||
name: 'ui_ticket_zoom_article_email_subject',
|
||||
|
|
|
@ -1724,8 +1724,8 @@ msgstr ""
|
|||
msgid "Clone"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_description.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_error_modal.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_description.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_error_modal.coffee
|
||||
#: app/assets/javascripts/app/controllers/_plugin/maintenance.coffee
|
||||
#: app/assets/javascripts/app/controllers/_settings/area_proxy.coffee
|
||||
#: app/assets/javascripts/app/controllers/widget/error_modal.coffee
|
||||
|
@ -1862,7 +1862,6 @@ msgstr ""
|
|||
msgid "Configure Base"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/tag.coffee
|
||||
#: app/assets/javascripts/app/controllers/taskbar_widget.coffee
|
||||
#: app/assets/javascripts/app/views/agent_ticket_view/bulk.jst.eco
|
||||
|
@ -1873,6 +1872,11 @@ msgstr ""
|
|||
msgid "Confirm/submit dialog"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_destroy_confirm.coffee
|
||||
msgid "Confirmation"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/views/knowledge_base/delete.coffee
|
||||
msgid "Confirmation failed."
|
||||
msgstr ""
|
||||
|
@ -2682,6 +2686,11 @@ msgstr ""
|
|||
msgid "Defines if the GitLab (http://www.gitlab.com) integration is enabled or not."
|
||||
msgstr ""
|
||||
|
||||
#: db/migrate/20220119102815_issue3924_confirmation_dialog.rb
|
||||
#: db/seeds/settings.rb
|
||||
msgid "Defines if the agent has to accept a confirmation dialog when changing the article visibility to \"public\"."
|
||||
msgstr ""
|
||||
|
||||
#: db/seeds/settings.rb
|
||||
msgid "Defines if the core workflow communication should run over ajax instead of websockets."
|
||||
msgstr ""
|
||||
|
@ -3120,7 +3129,7 @@ msgstr ""
|
|||
msgid "Department"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_description.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_description.coffee
|
||||
#: app/assets/javascripts/app/views/calendar/holiday_selector.jst.eco
|
||||
#: app/assets/javascripts/app/views/calendar/index.jst.eco
|
||||
#: app/assets/javascripts/app/views/channel/chat.jst.eco
|
||||
|
@ -3250,11 +3259,15 @@ msgstr ""
|
|||
msgid "Do not sign email"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/tag.coffee
|
||||
msgid "Do you really want to delete this object?"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/article_public_confirm.coffee
|
||||
msgid "Do you really want to set the visibility of this article to \"public\"?"
|
||||
msgstr ""
|
||||
|
||||
#: db/seeds/object_manager_attributes.rb
|
||||
msgid "Domain"
|
||||
msgstr ""
|
||||
|
@ -3762,7 +3775,7 @@ msgstr ""
|
|||
msgid "Enter your username or email address"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_error_modal.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_error_modal.coffee
|
||||
#: app/assets/javascripts/app/controllers/_profile/out_of_office.coffee
|
||||
#: app/assets/javascripts/app/controllers/_settings/area_proxy.coffee
|
||||
#: app/assets/javascripts/app/controllers/ticket_zoom.coffee
|
||||
|
@ -4582,7 +4595,7 @@ msgstr ""
|
|||
msgid "Hi! Which one of our products?"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/organization_profile.coffee
|
||||
#: app/assets/javascripts/app/controllers/ticket_zoom/sidebar_ticket.coffee
|
||||
#: app/assets/javascripts/app/controllers/user_profile.coffee
|
||||
|
@ -6590,6 +6603,11 @@ msgstr ""
|
|||
msgid "Note - default visibility"
|
||||
msgstr ""
|
||||
|
||||
#: db/migrate/20220119102815_issue3924_confirmation_dialog.rb
|
||||
#: db/seeds/settings.rb
|
||||
msgid "Note - visibility confirmation dialog"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/models/email_address.coffee
|
||||
#: app/assets/javascripts/app/models/group.coffee
|
||||
#: app/assets/javascripts/app/models/job.coffee
|
||||
|
@ -7386,6 +7404,10 @@ msgstr ""
|
|||
msgid "Publish"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/article_public_confirm.coffee
|
||||
msgid "Publish Article"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/views/popover/kb_generic.jst.eco
|
||||
msgid "Published at"
|
||||
msgstr ""
|
||||
|
@ -8960,7 +8982,7 @@ msgstr ""
|
|||
msgid "The issue could not be saved."
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_new.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_new.coffee
|
||||
#: app/assets/javascripts/app/controllers/_channel/_email_signature.coffee
|
||||
#: app/assets/javascripts/app/controllers/agent_ticket_create.coffee
|
||||
#: app/assets/javascripts/app/controllers/customer_ticket_create.coffee
|
||||
|
@ -8970,7 +8992,7 @@ msgstr ""
|
|||
msgid "The object could not be created."
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_edit.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_edit.coffee
|
||||
#: app/assets/javascripts/app/controllers/_channel/sms.coffee
|
||||
#: app/assets/javascripts/app/controllers/_settings/area_switch.coffee
|
||||
#: app/assets/javascripts/app/controllers/_settings/area_ticket_number.coffee
|
||||
|
@ -9187,7 +9209,7 @@ msgstr ""
|
|||
msgid "This signature is inactive, it won't be included in the reply. Change state <a href=\"#channels/email\">here</a>"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
msgid "This ticket was merged into"
|
||||
msgstr ""
|
||||
|
||||
|
@ -9210,7 +9232,7 @@ msgstr ""
|
|||
msgid "Thursday"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_manage/ticket.coffee
|
||||
#: app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee
|
||||
#: app/assets/javascripts/app/controllers/_ui_element/core_workflow_condition.coffee
|
||||
|
@ -10442,6 +10464,7 @@ msgstr ""
|
|||
msgid "Yellow"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
|
@ -10933,7 +10956,7 @@ msgstr ""
|
|||
msgid "default"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/data_privacy.coffee
|
||||
#: app/assets/javascripts/app/controllers/knowledge_base/sidebar/attachments.coffee
|
||||
#: app/assets/javascripts/app/controllers/ticket_zoom/article_action/delete.coffee
|
||||
|
@ -11026,7 +11049,7 @@ msgstr ""
|
|||
msgid "for an agent to respond"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
msgid "from"
|
||||
msgstr ""
|
||||
|
||||
|
@ -11358,7 +11381,7 @@ msgstr ""
|
|||
msgid "select attachment…"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
msgid "sent to"
|
||||
msgstr ""
|
||||
|
||||
|
@ -11446,7 +11469,7 @@ msgstr ""
|
|||
msgid "telegram personal-message"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
#: lib/calendar_subscriptions/tickets.rb
|
||||
msgid "ticket"
|
||||
msgstr ""
|
||||
|
@ -11515,7 +11538,7 @@ msgstr ""
|
|||
msgid "updated"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_history.coffee
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee
|
||||
msgid "was merged into this ticket"
|
||||
msgstr ""
|
||||
|
||||
|
@ -11543,7 +11566,6 @@ msgstr ""
|
|||
msgid "within next (relative)"
|
||||
msgstr ""
|
||||
|
||||
#: app/assets/javascripts/app/controllers/_application_controller/generic_destroy_confirm.coffee
|
||||
#: app/assets/javascripts/app/controllers/_ui_element/boolean.coffee
|
||||
#: app/assets/javascripts/app/controllers/tag.coffee
|
||||
#: app/assets/javascripts/app/views/object_manager/attribute/boolean.jst.eco
|
||||
|
|
|
@ -2440,4 +2440,68 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|||
expect(ticket.reload[field_name]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Add confirmation dialog on visibility change of an article or in article creation #3924', authenticated_as: :authenticate do
|
||||
let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
|
||||
let(:article) { create(:ticket_article, ticket: ticket) }
|
||||
|
||||
before do
|
||||
visit "#ticket/zoom/#{article.ticket.id}"
|
||||
end
|
||||
|
||||
context 'when dialog is disabled' do
|
||||
def authenticate
|
||||
true
|
||||
end
|
||||
|
||||
it 'does set the article internal and external for existing articles' do
|
||||
expect { page.find('.js-ArticleAction[data-type=internal]').click }.to change { article.reload.internal }.to(true)
|
||||
expect { page.find('.js-ArticleAction[data-type=public]').click }.to change { article.reload.internal }.to(false)
|
||||
end
|
||||
|
||||
it 'does set the article internal and external for new article' do
|
||||
page.find('.js-writeArea').click({ x: 5, y: 5 })
|
||||
expect(page).to have_css('.article-new .icon-internal')
|
||||
expect(page).to have_no_css('.article-new .icon-public')
|
||||
|
||||
page.find('.article-new .icon-internal').click
|
||||
expect(page).to have_no_css('.article-new .icon-internal')
|
||||
expect(page).to have_css('.article-new .icon-public')
|
||||
|
||||
page.find('.article-new .icon-public').click
|
||||
expect(page).to have_css('.article-new .icon-internal')
|
||||
expect(page).to have_no_css('.article-new .icon-public')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dialog is enabled' do
|
||||
def authenticate
|
||||
Setting.set('ui_ticket_zoom_article_visibility_confirmation_dialog', true)
|
||||
true
|
||||
end
|
||||
|
||||
it 'does set the article internal and external for existing articles' do
|
||||
expect { page.find('.js-ArticleAction[data-type=internal]').click }.to change { article.reload.internal }.to(true)
|
||||
page.find('.js-ArticleAction[data-type=public]').click
|
||||
expect(page).to have_css('.modal-dialog')
|
||||
expect { find('.modal-dialog button[type=submit]').click }.to change { article.reload.internal }.to(false)
|
||||
end
|
||||
|
||||
it 'does set the article internal and external for new article' do
|
||||
page.find('.js-writeArea').click({ x: 5, y: 5 })
|
||||
expect(page).to have_css('.article-new .icon-internal')
|
||||
expect(page).to have_no_css('.article-new .icon-public')
|
||||
|
||||
page.find('.article-new .icon-internal').click
|
||||
expect(page).to have_css('.modal-dialog')
|
||||
find('.modal-dialog button[type=submit]').click
|
||||
expect(page).to have_no_css('.article-new .icon-internal')
|
||||
expect(page).to have_css('.article-new .icon-public')
|
||||
|
||||
page.find('.article-new .icon-public').click
|
||||
expect(page).to have_css('.article-new .icon-internal')
|
||||
expect(page).to have_no_css('.article-new .icon-public')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue