Fixed issue #949 - Sometimes pending time is show as first ticket attribute.
This commit is contained in:
parent
8d725040a9
commit
1e311034a0
2 changed files with 49 additions and 3 deletions
|
@ -828,14 +828,29 @@ set new attributes of model (remove already available attributes)
|
||||||
@updateAttributes: (attributes) ->
|
@updateAttributes: (attributes) ->
|
||||||
return if !@className
|
return if !@className
|
||||||
if _.isEmpty(@org_configure_attributes)
|
if _.isEmpty(@org_configure_attributes)
|
||||||
@org_configure_attributes = clone(@configure_attributes)
|
|
||||||
|
# use jquery instead of ._clone() because we need a deep copy of the obj
|
||||||
|
@org_configure_attributes = $.extend(true, [], @configure_attributes)
|
||||||
for attribute in attributes
|
for attribute in attributes
|
||||||
@attributes.push attribute.name
|
@attributes.push attribute.name
|
||||||
|
|
||||||
|
found = false
|
||||||
|
for attribute_model, index in @configure_attributes
|
||||||
|
continue if attribute_model.name != attribute.name
|
||||||
|
|
||||||
|
@configure_attributes[index] = _.extend(attribute_model, attribute)
|
||||||
|
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
|
||||||
|
if !found
|
||||||
@configure_attributes.push attribute
|
@configure_attributes.push attribute
|
||||||
|
|
||||||
@resetAttributes: ->
|
@resetAttributes: ->
|
||||||
return if _.isEmpty(@org_configure_attributes)
|
return if _.isEmpty(@org_configure_attributes)
|
||||||
@configure_attributes = @org_configure_attributes
|
|
||||||
|
# use jquery instead of ._clone() because we need a deep copy of the obj
|
||||||
|
@configure_attributes = $.extend(true, [], @org_configure_attributes)
|
||||||
|
|
||||||
@resetCallbacks: ->
|
@resetCallbacks: ->
|
||||||
@SUBSCRIPTION_ITEM = {}
|
@SUBSCRIPTION_ITEM = {}
|
||||||
|
|
|
@ -407,4 +407,35 @@ App.Delay.set( function() {
|
||||||
1400
|
1400
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test("updateAttributes will change existing attributes and add new ones", function() {
|
||||||
|
App.Ticket.resetAttributes();
|
||||||
|
|
||||||
|
var attributesBefore = _.clone(App.Ticket.configure_attributes);
|
||||||
|
var updateAttribute = _.clone(attributesBefore[0]);
|
||||||
|
|
||||||
|
updateAttribute['new_option_1239393'] = 1;
|
||||||
|
|
||||||
|
App.Ticket.updateAttributes([
|
||||||
|
updateAttribute,
|
||||||
|
{
|
||||||
|
name: 'new_attribute_1010101',
|
||||||
|
display: 'New Attribute',
|
||||||
|
tag: 'input',
|
||||||
|
readonly: 1,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
var attributesAfterUpdate = _.clone(App.Ticket.configure_attributes);
|
||||||
|
|
||||||
|
equal(attributesAfterUpdate.length, attributesBefore.length + 1, 'new attributes list contains 1 more elements')
|
||||||
|
equal(attributesAfterUpdate[attributesAfterUpdate.length - 1]['name'], 'new_attribute_1010101', 'new attributes list contains the new element')
|
||||||
|
equal(attributesAfterUpdate[0]['new_option_1239393'], 1, 'first element of the new attributes got updated with the new option')
|
||||||
|
|
||||||
|
App.Ticket.resetAttributes();
|
||||||
|
var attributesAfterReset = _.clone(App.Ticket.configure_attributes);
|
||||||
|
|
||||||
|
equal(attributesAfterReset.length, attributesBefore.length, 'new attributes list has the same elements after reset')
|
||||||
|
equal(attributesAfterReset[0]['new_option_1239393'], undefined, 'first element of the new attributes has no attribute new_option_1239393')
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue