Merge branch 'develop' of git.znuny.com:zammad/zammad into develop

This commit is contained in:
Martin Edenhofer 2018-08-09 06:03:50 +02:00
commit c73d48485b
3 changed files with 67 additions and 57 deletions

View file

@ -60,68 +60,23 @@ class App.ChannelEmailFilter extends App.Controller
new: (e) =>
e.preventDefault()
new App.ChannelEmailFilterEdit(
new App.ControllerGenericNew(
pageData:
object: 'Postmaster Filter'
genericObject: 'PostmasterFilter'
container: @el.closest('.content')
callback: @load
)
edit: (id, e) =>
e.preventDefault()
new App.ChannelEmailFilterEdit(
object: App.PostmasterFilter.find(id)
new App.ControllerGenericEdit(
id: id,
pageData:
object: 'Postmaster Filter'
genericObject: 'PostmasterFilter'
container: @el.closest('.content')
)
class App.ChannelEmailFilterEdit extends App.ControllerModal
buttonClose: true
buttonCancel: true
buttonSubmit: true
head: 'Postmaster Filter'
content: =>
if @object
@form = new App.ControllerForm(
model: App.PostmasterFilter,
params: @object,
autofocus: true,
)
else
@form = new App.ControllerForm(
model: App.PostmasterFilter,
autofocus: true,
)
@form.form
onSubmit: (e) =>
e.preventDefault()
# get params
params = @formParam(e.target)
params['channel'] = 'email'
object = @object || new App.PostmasterFilter
object.load(params)
# validate form
errors = @form.validate(params)
# show errors in form
if errors
@log 'error', errors
@formValidate(form: e.target, errors: errors)
return false
# disable form
@formDisable(e)
# save object
object.save(
done: =>
@close()
fail: (settings, details) =>
@log 'errors', details
@formEnable(e)
@form.showAlert(details.error_human || details.error || 'Unable to create object!')
callback: @load
)
class App.ChannelEmailSignature extends App.Controller

View file

@ -21,3 +21,6 @@ class App.PostmasterFilter extends App.Model
'name',
]
@configure_clone = true
@on 'create', (newRecord) ->
newRecord.channel = 'email'

View file

@ -128,4 +128,56 @@ class AdminChannelEmailTest < TestCase
end
# test the creation and cloning of Postmaster filters
# confirm fix for issue #2170 - Cannot clone PostmasterFilter
def test_filter_clone
filter_name = "Test Filter #{rand(999_999)}"
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
click(css: 'a[href="#manage"]')
click(css: '.content.active a[href="#channels/email"]')
click(css: '.content.active a[href="#c-filter"]')
# create a new email filter
click(css: '.content.active a[data-type="new"]')
modal_ready()
set(
css: '.modal input[name="name"]',
value: filter_name,
)
set(
css: '.modal input[name="match::from::value"]',
value: 'target',
)
click(css: '.modal .js-submit')
modal_disappear()
watch_for(
css: '.content.active .table',
value: filter_name,
)
# now clone filter that we just created
click(css: '.content.active .table #tableActions')
click(css: '.content.active .table .dropdown .js-clone')
modal_ready()
click(css: '.modal .js-submit')
modal_disappear()
# confirm the clone exists in the table
watch_for(
css: '.content.active .table',
value: "Clone: #{filter_name}",
)
end
end