Fixed issue #987 - Creating a custom overview using tags results in error 500.
This commit is contained in:
parent
3b40449a9d
commit
f1a7a08a6a
4 changed files with 72 additions and 70 deletions
|
@ -25,5 +25,5 @@ class App.UiElement.tag
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
$('#' + attribute.id ).parent().css('height', 'auto')
|
$('#' + attribute.id ).parent().css('height', 'auto')
|
||||||
App.Delay.set(a, 120, undefined, 'tags')
|
App.Delay.set(a, 500, undefined, 'tags')
|
||||||
item
|
item
|
||||||
|
|
|
@ -82,29 +82,40 @@ class App.UiElement.ticket_selector
|
||||||
elements["#{groupKey}.#{config.name}"] = config
|
elements["#{groupKey}.#{config.name}"] = config
|
||||||
[defaults, groups, elements]
|
[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 = {}) ->
|
@render: (attribute, params = {}) ->
|
||||||
|
|
||||||
[defaults, groups, elements] = @defaults(attribute)
|
[defaults, groups, elements] = @defaults(attribute)
|
||||||
|
|
||||||
selector = @buildAttributeSelector(groups, elements)
|
|
||||||
|
|
||||||
# return item
|
|
||||||
item = $( App.view('generic/ticket_selector')(attribute: attribute) )
|
item = $( App.view('generic/ticket_selector')(attribute: attribute) )
|
||||||
item.find('.js-attributeSelector').prepend(selector)
|
|
||||||
|
|
||||||
# add filter
|
# add filter
|
||||||
item.find('.js-add').bind('click', (e) =>
|
item.delegate('.js-add', 'click', (e) =>
|
||||||
element = $(e.target).closest('.js-filterElement')
|
element = $(e.target).closest('.js-filterElement')
|
||||||
elementClone = element.clone(true)
|
|
||||||
element.after(elementClone)
|
# add first available attribute
|
||||||
elementClone.find('.js-attributeSelector select').trigger('change')
|
field = undefined
|
||||||
@updateAttributeSelectors(item)
|
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
|
if attribute.preview isnt false
|
||||||
@preview(item)
|
@preview(item)
|
||||||
)
|
)
|
||||||
|
|
||||||
# remove filter
|
# remove filter
|
||||||
item.find('.js-remove').bind('click', (e) =>
|
item.delegate('.js-remove', 'click', (e) =>
|
||||||
return if $(e.currentTarget).hasClass('is-disabled')
|
return if $(e.currentTarget).hasClass('is-disabled')
|
||||||
$(e.target).closest('.js-filterElement').remove()
|
$(e.target).closest('.js-filterElement').remove()
|
||||||
@updateAttributeSelectors(item)
|
@updateAttributeSelectors(item)
|
||||||
|
@ -118,45 +129,34 @@ class App.UiElement.ticket_selector
|
||||||
for groupAndAttribute, meta of params[attribute.name]
|
for groupAndAttribute, meta of params[attribute.name]
|
||||||
selectorExists = true
|
selectorExists = true
|
||||||
|
|
||||||
# get selector rows
|
# build and append
|
||||||
elementFirst = item.find('.js-filterElement').first()
|
row = @rowContainer(groups, elements, attribute)
|
||||||
elementLast = item.find('.js-filterElement').last()
|
@rebuildAttributeSelectors(item, row, groupAndAttribute, elements, meta, attribute)
|
||||||
|
item.filter('.js-filter').append(row)
|
||||||
# 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()
|
|
||||||
|
|
||||||
else
|
else
|
||||||
for groupAndAttribute in defaults
|
for groupAndAttribute in defaults
|
||||||
|
|
||||||
# get selector rows
|
# build and append
|
||||||
elementFirst = item.find('.js-filterElement').first()
|
row = @rowContainer(groups, elements, attribute)
|
||||||
elementLast = item.find('.js-filterElement').last()
|
@rebuildAttributeSelectors(item, row, groupAndAttribute, elements, {}, attribute)
|
||||||
|
item.filter('.js-filter').append(row)
|
||||||
# clone, rebuild and append
|
|
||||||
elementClone = elementFirst.clone(true)
|
|
||||||
@rebuildAttributeSelectors(item, elementClone, groupAndAttribute, elements, {}, attribute)
|
|
||||||
elementLast.after(elementClone)
|
|
||||||
item.find('.js-filterElement').first().remove()
|
|
||||||
|
|
||||||
# change attribute selector
|
# change attribute selector
|
||||||
item.find('.js-attributeSelector select').bind('change', (e) =>
|
item.delegate('.js-attributeSelector select', 'change', (e) =>
|
||||||
elementRow = $(e.target).closest('.js-filterElement')
|
elementRow = $(e.target).closest('.js-filterElement')
|
||||||
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
|
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
|
||||||
|
return if !groupAndAttribute
|
||||||
@rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, {}, attribute)
|
@rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, {}, attribute)
|
||||||
@updateAttributeSelectors(item)
|
@updateAttributeSelectors(item)
|
||||||
)
|
)
|
||||||
|
|
||||||
# change operator selector
|
# change operator selector
|
||||||
item.on('change', '.js-operator select', (e) =>
|
item.delegate('.js-operator select', 'change', (e) =>
|
||||||
elementRow = $(e.target).closest('.js-filterElement')
|
elementRow = $(e.target).closest('.js-filterElement')
|
||||||
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
|
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
|
# bind for preview
|
||||||
|
@ -244,9 +244,9 @@ class App.UiElement.ticket_selector
|
||||||
if groupAndAttribute
|
if groupAndAttribute
|
||||||
elementRow.find('.js-attributeSelector select').val(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')
|
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
|
||||||
|
|
||||||
name = "#{attribute.name}::#{groupAndAttribute}::operator"
|
name = "#{attribute.name}::#{groupAndAttribute}::operator"
|
||||||
|
@ -284,9 +284,9 @@ class App.UiElement.ticket_selector
|
||||||
|
|
||||||
elementRow.find('.js-operator select').replaceWith(selection)
|
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')
|
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
|
||||||
currentPreCondition = elementRow.find('.js-preCondition option:selected').attr('value')
|
currentPreCondition = elementRow.find('.js-preCondition option:selected').attr('value')
|
||||||
|
|
||||||
|
@ -318,6 +318,7 @@ class App.UiElement.ticket_selector
|
||||||
if !preCondition
|
if !preCondition
|
||||||
elementRow.find('.js-preCondition select').html('')
|
elementRow.find('.js-preCondition select').html('')
|
||||||
elementRow.find('.js-preCondition').addClass('hide')
|
elementRow.find('.js-preCondition').addClass('hide')
|
||||||
|
return if !buildValue
|
||||||
toggleValue()
|
toggleValue()
|
||||||
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||||
return
|
return
|
||||||
|
@ -350,6 +351,7 @@ class App.UiElement.ticket_selector
|
||||||
toggleValue()
|
toggleValue()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return if !buildValue
|
||||||
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||||
toggleValue()
|
toggleValue()
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,4 @@
|
||||||
<div class="horizontal-filters">
|
<div class="horizontal-filters js-filter">
|
||||||
<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>
|
</div>
|
||||||
<div class="js-preview <% if @attribute.preview is false: %>hide<% end %>">
|
<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>
|
<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>
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in a new issue