Skip to content

Commit

Permalink
[5.3] MSPB-365: Replace ignore completed elsewhere control multiselec…
Browse files Browse the repository at this point in the history
…t option (#545)

* Replace multi option element

* Implement system config default

* custom api endpoint and review fixes
  • Loading branch information
masmerino13 committed Jun 6, 2024
1 parent d95b99d commit a364853
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
3 changes: 2 additions & 1 deletion i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@
"__version": "3.19",
"ignoreCompletedElsewhere": {
"label": "Ignore Completed Elsewhere",
"help": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere."
"help": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere.",
"systemDefault": "System Default"
},
"__comment": "UI-377: Adding Restart device feature",
"__version": "3.21",
Expand Down
39 changes: 36 additions & 3 deletions submodules/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,13 @@ define(function(require) {
});
});

templateDevice.find('.btn-group-wrapper button.monster-button-ignore').on('click', function(e) {
e.preventDefault();
var $this = $(this);
$this.siblings().removeClass('selected monster-button-primary');
$this.addClass('selected monster-button-primary');
});

var popup = monster.ui.dialog(templateDevice, {
title: popupTitle,
dialogClass: 'voip-edit-device-popup'
Expand Down Expand Up @@ -729,6 +736,17 @@ define(function(require) {
.value();
};

template.find('.ignore-completed-elsewhere').each(function() {
var $this = $(this),
hasValue = $this.find('button.selected').length,
value = hasValue ? $this.find('button.selected').data('value') : 'default';

// If value is set to something else than account default then we set the enabled boolean
if (value && value !== 'default') {
formData.ignore_completed_elsewhere = value === 'on'
}
});

if ('mac_address' in formData) {
formData.mac_address = monster.util.formatMacAddress(formData.mac_address);
}
Expand Down Expand Up @@ -1064,7 +1082,10 @@ define(function(require) {
value: false
}]
}
}
},
system_ignore_completed_elsewhere: _.get(data, 'configs.ignore_completed_elsewhere', true)
? self.i18n.active().on
: self.i18n.active().off
}, deviceData);
},

Expand Down Expand Up @@ -1167,7 +1188,7 @@ define(function(require) {
outbound_privacy: "none"
},
sip: _.merge({
ignore_completed_elsewhere: false,
ignore_completed_elsewhere: 'true',
}, _.pick(sipSettings.sip, ['password', 'username'])),
media: {
webrtc: false,
Expand Down Expand Up @@ -1415,7 +1436,19 @@ define(function(require) {
callback(null, users);
}
});
}
},
configs: function(callback) {
self.callApi({
resource: 'configs.get',
data: {
accountId: self.accountId,
endpoint: 'kazoo_endpoint'
},
success: function(data, status) {
callback(null, data.data);
}
});
},
}, function(error, results) {
waterfallCb(null, results);
});
Expand Down
10 changes: 10 additions & 0 deletions submodules/devices/devices.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@
width: 700px;
}

.voip-edit-device-popup .edit-device .btn-group-controls {
font-size: 1rem;
margin-left: 8px;
}

.voip-edit-device-popup .edit-device .ignore-completed-elsewhere-group .control-label{
width: 200px;
margin-left: 22px;
}

.voip-edit-device-popup .edit-device .actions {
border-top: 1px solid #CCCCCC;
height: 30px;
Expand Down
11 changes: 11 additions & 0 deletions submodules/devices/views/devices-sip_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@
</label>
</div>

<div class="control-group ignore-completed-elsewhere-group">
<label class="control-label">{{ i18n.devices.popupSettings.miscellaneous.ignoreCompletedElsewhere.label }}</label>
<div class="btn-group-wrapper">
<div class="btn-group btn-group-controls ignore-completed-elsewhere">
<button data-value="off" class="monster-button monster-button-ignore{{#compare ignore_completed_elsewhere "===" false}} monster-button-primary selected{{/compare}}">{{ i18n.off }}</button>
<button data-value="default" class="monster-button monster-button-ignore{{#compare ignore_completed_elsewhere "===" undefined}} monster-button-primary selected{{/compare}}">{{ i18n.devices.popupSettings.miscellaneous.ignoreCompletedElsewhere.systemDefault }} ({{ system_ignore_completed_elsewhere }})</button>
<button data-value="on" class="monster-button monster-button-ignore{{#compare ignore_completed_elsewhere "===" true}} monster-button-primary selected{{/compare}}">{{ i18n.on }}</button>
</div>
</div>
</div>

<div class="control-group">
<label for="outbound_privacy" class="control-label checkbox">
{{i18n.commonMisc.outboundPrivacy.label}}
Expand Down

0 comments on commit a364853

Please sign in to comment.