Fixed issue #987 - Creating a custom overview using tags results in error 500.

This commit is contained in:
Rolf Schmidt 2017-04-26 14:56:47 +02:00
parent 5ee2c5b02a
commit 98cac39c80
4 changed files with 72 additions and 70 deletions

View file

@ -25,5 +25,5 @@ class App.UiElement.tag
true
)
$('#' + attribute.id ).parent().css('height', 'auto')
App.Delay.set(a, 120, undefined, 'tags')
App.Delay.set(a, 500, undefined, 'tags')
item

View file

@ -82,29 +82,40 @@ class App.UiElement.ticket_selector
elements["#{groupKey}.#{config.name}"] = config
[defaults, groups, elements]
@rowContainer: (groups, elements, attribute) ->
row = $( App.view('generic/ticket_selector_row')(attribute: attribute) )
selector = @buildAttributeSelector(groups, elements)
row.find('.js-attributeSelector').prepend(selector)
row
@render: (attribute, params = {}) ->
[defaults, groups, elements] = @defaults(attribute)
selector = @buildAttributeSelector(groups, elements)
# return item
item = $( App.view('generic/ticket_selector')(attribute: attribute) )
item.find('.js-attributeSelector').prepend(selector)
# add filter
item.find('.js-add').bind('click', (e) =>
item.delegate('.js-add', 'click', (e) =>
element = $(e.target).closest('.js-filterElement')
elementClone = element.clone(true)
element.after(elementClone)
elementClone.find('.js-attributeSelector select').trigger('change')
@updateAttributeSelectors(item)
# add first available attribute
field = undefined
for groupAndAttribute, _config of elements
if !item.find(".js-attributeSelector [value=\"#{groupAndAttribute}\"]:selected").get(0)
field = groupAndAttribute
break
return if !field
row = @rowContainer(groups, elements, attribute)
element.after(row)
row.find('.js-attributeSelector select').trigger('change')
@rebuildAttributeSelectors(item, row, field, elements, {}, attribute)
if attribute.preview isnt false
@preview(item)
)
# remove filter
item.find('.js-remove').bind('click', (e) =>
item.delegate('.js-remove', 'click', (e) =>
return if $(e.currentTarget).hasClass('is-disabled')
$(e.target).closest('.js-filterElement').remove()
@updateAttributeSelectors(item)
@ -118,45 +129,34 @@ class App.UiElement.ticket_selector
for groupAndAttribute, meta of params[attribute.name]
selectorExists = true
# get selector rows
elementFirst = item.find('.js-filterElement').first()
elementLast = item.find('.js-filterElement').last()
# clone, rebuild and append
elementClone = elementFirst.clone(true)
@rebuildAttributeSelectors(item, elementClone, groupAndAttribute, elements, meta, attribute)
elementLast.after(elementClone)
# remove first dummy row
if selectorExists
item.find('.js-filterElement').first().remove()
# build and append
row = @rowContainer(groups, elements, attribute)
@rebuildAttributeSelectors(item, row, groupAndAttribute, elements, meta, attribute)
item.filter('.js-filter').append(row)
else
for groupAndAttribute in defaults
# get selector rows
elementFirst = item.find('.js-filterElement').first()
elementLast = item.find('.js-filterElement').last()
# clone, rebuild and append
elementClone = elementFirst.clone(true)
@rebuildAttributeSelectors(item, elementClone, groupAndAttribute, elements, {}, attribute)
elementLast.after(elementClone)
item.find('.js-filterElement').first().remove()
# build and append
row = @rowContainer(groups, elements, attribute)
@rebuildAttributeSelectors(item, row, groupAndAttribute, elements, {}, attribute)
item.filter('.js-filter').append(row)
# change attribute selector
item.find('.js-attributeSelector select').bind('change', (e) =>
item.delegate('.js-attributeSelector select', 'change', (e) =>
elementRow = $(e.target).closest('.js-filterElement')
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
return if !groupAndAttribute
@rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, {}, attribute)
@updateAttributeSelectors(item)
)
# change operator selector
item.on('change', '.js-operator select', (e) =>
item.delegate('.js-operator select', 'change', (e) =>
elementRow = $(e.target).closest('.js-filterElement')
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
@buildOperator(item, elementRow, groupAndAttribute, elements, {}, attribute)
return if !groupAndAttribute
@buildOperator(item, elementRow, groupAndAttribute, elements, {}, attribute, false)
)
# bind for preview
@ -244,9 +244,9 @@ class App.UiElement.ticket_selector
if groupAndAttribute
elementRow.find('.js-attributeSelector select').val(groupAndAttribute)
@buildOperator(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
@buildOperator(elementFull, elementRow, groupAndAttribute, elements, meta, attribute, true)
@buildOperator: (elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
@buildOperator: (elementFull, elementRow, groupAndAttribute, elements, meta, attribute, buildValue) ->
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
name = "#{attribute.name}::#{groupAndAttribute}::operator"
@ -284,9 +284,9 @@ class App.UiElement.ticket_selector
elementRow.find('.js-operator select').replaceWith(selection)
@buildPreCondition(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
@buildPreCondition(elementFull, elementRow, groupAndAttribute, elements, meta, attribute, buildValue)
@buildPreCondition: (elementFull, elementRow, groupAndAttribute, elements, meta, attributeConfig) ->
@buildPreCondition: (elementFull, elementRow, groupAndAttribute, elements, meta, attributeConfig, buildValue = true) ->
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
currentPreCondition = elementRow.find('.js-preCondition option:selected').attr('value')
@ -318,6 +318,7 @@ class App.UiElement.ticket_selector
if !preCondition
elementRow.find('.js-preCondition select').html('')
elementRow.find('.js-preCondition').addClass('hide')
return if !buildValue
toggleValue()
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
return
@ -350,6 +351,7 @@ class App.UiElement.ticket_selector
toggleValue()
)
return if !buildValue
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
toggleValue()

View file

@ -1,34 +1,4 @@
<div class="horizontal-filters">
<div class="horizontal-filter js-filterElement">
<div class="horizontal-filter-body">
<div class="controls">
<div class="u-positionOrigin js-attributeSelector">
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls">
<div class="u-positionOrigin js-operator">
<select></select>
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls">
<div class="u-positionOrigin js-preCondition">
<select></select>
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls js-value horizontal"></div>
</div>
<div class="filter-controls">
<div class="filter-control filter-control-remove js-remove" title="<%- @Ti('Remove') %>">
<%- @Icon('minus-small') %>
</div>
<div class="filter-control filter-control-add js-add" title="<%- @Ti('Add') %>">
<%- @Icon('plus-small') %>
</div>
</div>
</div>
<div class="horizontal-filters js-filter">
</div>
<div class="js-preview <% if @attribute.preview is false: %>hide<% end %>">
<h3><%- @T('Preview') %><span class="subtitle js-previewCounterContainer hide"> <span class="u-highlight js-previewCounter">?</span> <%- @T('matches') %></span> <span class="tiny loading icon js-previewLoader hide" style="margin-left: 3px;"></span></h3>

View file

@ -0,0 +1,30 @@
<div class="horizontal-filter js-filterElement">
<div class="horizontal-filter-body">
<div class="controls">
<div class="u-positionOrigin js-attributeSelector">
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls">
<div class="u-positionOrigin js-operator">
<select></select>
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls">
<div class="u-positionOrigin js-preCondition">
<select></select>
<%- @Icon('arrow-down', 'dropdown-arrow') %>
</div>
</div>
<div class="controls js-value horizontal"></div>
</div>
<div class="filter-controls">
<div class="filter-control filter-control-remove js-remove" title="<%- @Ti('Remove') %>">
<%- @Icon('minus-small') %>
</div>
<div class="filter-control filter-control-add js-add" title="<%- @Ti('Add') %>">
<%- @Icon('plus-small') %>
</div>
</div>
</div>