Added delete of channels and postmaster filters.

This commit is contained in:
Martin Edenhofer 2014-06-06 21:48:59 +02:00
parent 965fc4d303
commit fde2c0e43a
6 changed files with 118 additions and 45 deletions

View file

@ -258,7 +258,7 @@ class App.ControllerForm extends App.Controller
# postmaster_match # postmaster_match
else if attribute.tag is 'postmaster_match' else if attribute.tag is 'postmaster_match'
addItem = (key, displayName, el, defaultValue = '') => addItem = (key, displayName, el, defaultValue = '') =>
itemInput = $("<div>#{ displayName }: <input name=\"#{ key }\" type=\"input\" value=\"#{ defaultValue }\" class=\"form-control\"/><a href=\"#\" class=\"glyphicon glyphicon-minus remove\"></a></div>") itemInput = $("<div>#{ App.i18n.translateInline(displayName) }: <input name=\"#{ key }\" type=\"input\" value=\"#{ defaultValue }\" class=\"form-control\" required/><a href=\"#\" class=\"glyphicon glyphicon-minus remove\"></a></div>")
# remove on click # remove on click
itemInput.find('.remove').bind('click', (e) -> itemInput.find('.remove').bind('click', (e) ->
@ -307,11 +307,104 @@ class App.ControllerForm extends App.Controller
value: 'body' value: 'body'
name: 'Body' name: 'Body'
}, },
#{ {
# value: '-' value: ''
# name: '' name: '-'
# disable: true disable: true
#}, },
{
value: 'x-any-recipient'
name: 'Any Recipient'
},
{
value: ''
name: '-'
disable: true
},
{
value: ''
name: '- ' + App.i18n.translateInline('expert settings') + ' -'
disable: true
},
{
value: ''
name: '-'
disable: true
},
{
value: 'x-spam-flag'
name: 'X-Spam-Flag'
},
{
value: 'x-spam-level'
name: 'X-Spam-Level'
},
{
value: 'x-spam-score'
name: 'X-Spam-Score'
},
{
value: 'x-spam-status'
name: 'X-Spam-Status'
},
{
value: 'importance'
name: 'Importance'
},
{
value: 'x-priority'
name: 'X-Priority'
},
{
value: 'organization'
name: 'Organization'
},
{
value: 'x-original-to'
name: 'X-Original-To'
},
{
value: 'delivered-to'
name: 'Delivered-To'
},
{
value: 'envelope-to'
name: 'Envelope-To'
},
{
value: 'delivered-to'
name: 'Delivered-To'
},
{
value: 'return-path'
name: 'Return-Path'
},
{
value: 'mailing-list'
name: 'Mailing-List'
},
{
value: 'list-id'
name: 'List-Id'
},
{
value: 'list-archive'
name: 'List-Archive'
},
{
value: 'mailing-list'
name: 'Mailing-List'
},
{
value: 'auto-submitted'
name: 'Auto-Submitted'
},
{
value: 'x-loop'
name: 'X-Loop'
},
] ]
for listItem in loopData for listItem in loopData
listItem.value = "#{ attribute.name }::#{listItem.value}" listItem.value = "#{ attribute.name }::#{listItem.value}"
@ -339,7 +432,7 @@ class App.ControllerForm extends App.Controller
# postmaster_set # postmaster_set
else if attribute.tag is 'postmaster_set' else if attribute.tag is 'postmaster_set'
addItem = (key, displayName, el, defaultValue = '') => addItem = (key, displayName, el, defaultValue = '') =>
itemInput = $("<div>#{ displayName }: <input name=\"#{ key }\" type=\"input\" value=\"#{ defaultValue }\" class=\"form-control\"/><a href=\"#\" class=\"glyphicon glyphicon-minus remove\"></a></div>") itemInput = $("<div>#{ App.i18n.translateInline(displayName) }: <input name=\"#{ key }\" type=\"input\" value=\"#{ defaultValue }\" class=\"form-control\"/><a href=\"#\" class=\"glyphicon glyphicon-minus remove\"></a></div>")
# remove on click # remove on click
itemInput.find('.remove').bind('click', (e) -> itemInput.find('.remove').bind('click', (e) ->
@ -369,31 +462,6 @@ class App.ControllerForm extends App.Controller
# select shown attributes # select shown attributes
loopData = [ loopData = [
{
value: 'from'
name: 'From'
},
{
value: 'to'
name: 'To'
},
{
value: 'cc'
name: 'Cc'
},
{
value: 'subject'
name: 'Subject'
},
{
value: 'body'
name: 'Body'
},
{
value: ''
name: '-'
disable: true
},
{ {
value: 'x-zammad-ticket-priority' value: 'x-zammad-ticket-priority'
name: 'Ticket Priority' name: 'Ticket Priority'

View file

@ -101,7 +101,6 @@ class App.ControllerGenericEdit extends App.ControllerModal
class App.ControllerGenericIndex extends App.Controller class App.ControllerGenericIndex extends App.Controller
events: events:
'click [data-type=edit]': 'edit' 'click [data-type=edit]': 'edit'
'click [data-type=destroy]': 'destroy'
'click [data-type=new]': 'new' 'click [data-type=new]': 'new'
constructor: -> constructor: ->
@ -195,13 +194,6 @@ class App.ControllerGenericIndex extends App.Controller
genericObject: @genericObject genericObject: @genericObject
) )
destroy: (e) ->
e.preventDefault()
item = $(e.target).item( App[ @genericObject ] )
new DestroyConfirm(
item: item
)
new: (e) -> new: (e) ->
e.preventDefault() e.preventDefault()
new App.ControllerGenericNew( new App.ControllerGenericNew(
@ -209,7 +201,7 @@ class App.ControllerGenericIndex extends App.Controller
genericObject: @genericObject genericObject: @genericObject
) )
class DestroyConfirm extends App.ControllerModal class App.ControllerGenericDestroyConfirm extends App.ControllerModal
constructor: -> constructor: ->
super super
@render() @render()

View file

@ -79,7 +79,7 @@ class App.ControllerTable extends App.Controller
header.push { header.push {
name: row name: row
display: row display: row
} }
# collect data of col. types # collect data of col. types
dataTypesForCols = [] dataTypesForCols = []
@ -152,6 +152,17 @@ class App.ControllerTable extends App.Controller
# convert to jquery object # convert to jquery object
table = $(table) table = $(table)
# bind on delete dialog
if data.model && destroy
table.delegate('[data-type="destroy"]', 'click', (e) ->
e.preventDefault()
itemId = $(e.target).parents('tr').data('id')
item = data.model.find(itemId)
new App.ControllerGenericDestroyConfirm(
item: item
)
)
# enable checkbox bulk selection # enable checkbox bulk selection
if data.checkbox if data.checkbox
table.delegate('[name="bulk_all"]', 'click', (e) -> table.delegate('[name="bulk_all"]', 'click', (e) ->

View file

@ -2,3 +2,4 @@ class App.Channel extends App.Model
@configure 'Channel', 'adapter', 'area', 'options', 'group_id', 'active', 'updated_at' @configure 'Channel', 'adapter', 'area', 'options', 'group_id', 'active', 'updated_at'
@extend Spine.Model.Ajax @extend Spine.Model.Ajax
@url: @apiPath + '/channels' @url: @apiPath + '/channels'
@configure_delete = true

View file

@ -12,6 +12,7 @@ class App.PostmasterFilter extends App.Model
{ name: 'updated_at', display: 'Updated', type: 'time', readonly: 1 }, { name: 'updated_at', display: 'Updated', type: 'time', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', 'default': true, 'null': false, 'class': 'span4' }, { name: 'active', display: 'Active', tag: 'boolean', type: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
] ]
@configure_delete = true
@configure_overview = [ @configure_overview = [
'name', 'name',
] ]

View file

@ -386,7 +386,7 @@ test( "form postmaster filter", function() {
subject: 'some subject', subject: 'some subject',
}, },
set: { set: {
to: 'some@address', 'x-zammad-ticket-priority': '3 high',
'x-zammad-ticket-group': 'some group', 'x-zammad-ticket-group': 'some group',
}, },
} }
@ -411,12 +411,12 @@ test( "form postmaster filter", function() {
subject: 'some subject', subject: 'some subject',
}, },
set: { set: {
to: 'some@address', 'x-zammad-ticket-priority': '3 high',
'x-zammad-ticket-group': 'some group', 'x-zammad-ticket-group': 'some group',
}, },
}; };
deepEqual( params, test_params, 'form param check' ); deepEqual( params, test_params, 'form param check' );
el.find('[name="set::to"]').next().click() el.find('[name="set::x-zammad-ticket-priority"]').next().click()
App.Delay.set( function() { App.Delay.set( function() {
test( "form param check after remove click", function() { test( "form param check after remove click", function() {
params = App.ControllerForm.params( el ) params = App.ControllerForm.params( el )