Browse Source

UI-3156: Update base and ring callflow group title when the group title is edited (#96)

* revert this

* Revert "revert this"

This reverts commit b30c9c9c8d.

* Update base and ring group on group update

* Update ring and base group only if the group title was changed

* Add translations keys
Use string template instead of simple strings
Add new function for patch update

* Refactor patch update

* Improve group update
4.3
Ricardo Merino 7 years ago
committed by GitHub
parent
commit
8795e30b76
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 79 additions and 2 deletions
  1. +3
    -1
      i18n/en-US.json
  2. +76
    -1
      submodules/groups/groups.js

+ 3
- 1
i18n/en-US.json View File

@ -149,7 +149,9 @@
"__comment": "UI-2104: Adding a warning when adding a group with no endpoints",
"__version": "3.22",
"emptyEndpointsWarning": "You need to select at least one member to create a group"
"emptyEndpointsWarning": "You need to select at least one member to create a group",
"ringGroup": "{{name}} Ring Group",
"baseGroup": "{{name}} Base Group"
},
"devices": {


+ 76
- 1
submodules/groups/groups.js View File

@ -1045,17 +1045,69 @@ define(function(require) {
//formData = self.groupsCleanNameData(formData);
var repeats = _.get(data.callflow, 'flow.data.repeats');
data = $.extend(true, {}, data, formData);
var baseGroupName = self.getTemplate({
name: '!' + self.i18n.active().groups.baseGroup,
data: {
name: data.group.name
}
}),
ringGroupName = self.getTemplate({
name: '!' + self.i18n.active().groups.ringGroup,
data: {
name: data.group.name
}
});
monster.parallel([
function(callback) {
if (self.isGroupEdited(data, baseGroupName, repeats)) {
callback(null);
return;
}
self.groupsUpdate(data.group, function(data) {
callback(null);
});
},
function(callback) {
self.groupsUpdateCallflow(data.callflow, function(data) {
if (self.isGroupEdited(data, baseGroupName, repeats)) {
callback(null);
return;
}
self.groupsPatchCallflow({
data: {
callflowId: data.callflow.id,
data: {
name: baseGroupName,
flow: data.callflow.flow
}
},
success: function() {
callback(null);
}
});
},
function(callback) {
if (ringGroupName === data.callflowRingGroup.name) {
callback(null);
return;
}
self.groupsPatchCallflow({
data: {
callflowId: data.callflowRingGroup.id,
data: {
name: ringGroupName
}
},
success: function() {
callback(null);
}
});
}
], function(err, results) {
@ -1083,6 +1135,10 @@ define(function(require) {
});
},
isGroupEdited: function(data, baseGroupName, repeats) {
return baseGroupName === data.callflow.name && repeats === parseInt(_.get(data.callflow, 'flow.data.repeats'));
},
groupsBindNumbers: function(template, data) {
var self = this,
toastrMessages = self.i18n.active().groups.toastrMessages,
@ -1551,6 +1607,11 @@ define(function(require) {
self.groupsGetBaseRingGroup(groupId, function(data) {
callback(null, data);
});
},
callflowRingGroup: function(callback) {
self.groupsGetRingGroup(groupId, function(data) {
callback(null, data);
});
}
}, function(err, results) {
globalCallback && globalCallback(results);
@ -2111,6 +2172,20 @@ define(function(require) {
});
},
groupsPatchCallflow: function(args) {
var self = this;
self.callApi({
resource: 'callflow.patch',
data: _.merge({
accountId: self.accountId
}, args.data),
success: function(data) {
args.success(data.data);
}
});
},
groupsGetGroup: function(groupId, callback) {
var self = this;


Loading…
Cancel
Save