-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI-1219: Added the prepend feature for numbers as a common control
Conflicts: apps/common/app.js apps/common/i18n/en-US.json
- Loading branch information
Showing
8 changed files
with
211 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* NUMBER-PREPEND POPUP */ | ||
.trunkstore_popup.number-prepend { | ||
width: 510px; | ||
} | ||
|
||
.trunkstore_popup.number-prepend form, | ||
.trunkstore_popup.number-prepend input { | ||
margin: 0; | ||
} | ||
|
||
.trunkstore_popup.number-prepend .popup-content { | ||
padding: 15px 25px; | ||
} | ||
|
||
.trunkstore_popup.number-prepend .popup-content:not(:first-child) { | ||
border-top: 1px solid #ccc; | ||
} | ||
|
||
.trunkstore_popup.number-prepend .popup-content .popup-label { | ||
margin: 0 10px 0 0; | ||
display: inline-block; | ||
} | ||
|
||
.trunkstore_popup.number-prepend .help-box { | ||
margin-top: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
define(function(require){ | ||
var $ = require('jquery'), | ||
_ = require('underscore'), | ||
monster = require('monster'), | ||
toastr = require('toastr'); | ||
|
||
var numberPrepend = { | ||
|
||
requests: { | ||
}, | ||
|
||
subscribe: { | ||
'common.numberPrepend.renderPopup': 'numberPrependEdit' | ||
}, | ||
|
||
numberPrependEdit: function(args) { | ||
var self = this; | ||
|
||
self.numberPrependGetNumber(args.phoneNumber, function(dataNumber) { | ||
self.numberPrependRender(dataNumber.data, args.callbacks); | ||
}); | ||
}, | ||
|
||
numberPrependRender: function(dataNumber, callbacks) { | ||
var self = this, | ||
popup_html = $(monster.template(self, 'numberPrepend-layout', dataNumber.prepend || {})), | ||
popup; | ||
|
||
popup_html.find('.save').on('click', function(ev) { | ||
ev.preventDefault(); | ||
var prependFormData = monster.ui.getFormData('number_prepend'); | ||
prependFormData.enabled = (prependFormData.name && prependFormData.name.length > 0) ? true : false; | ||
|
||
_.extend(true, dataNumber, { prepend: prependFormData }); | ||
|
||
self.numberPrependUpdateNumber(dataNumber.id, dataNumber, | ||
function(data) { | ||
var phoneNumber = monster.util.formatPhoneNumber(data.data.id), | ||
template = monster.template(self, '!' + self.i18n.active().numberPrepend.successUpdate, { phoneNumber: phoneNumber }); | ||
|
||
toastr.success(template); | ||
|
||
popup.dialog('destroy').remove(); | ||
|
||
callbacks.success && callbacks.success(data); | ||
}, | ||
function(data) { | ||
callbacks.error && callbacks.error(data); | ||
} | ||
); | ||
|
||
}); | ||
|
||
popup_html.find('.cancel-link').on('click', function(e) { | ||
e.preventDefault(); | ||
popup.dialog('destroy').remove(); | ||
}); | ||
|
||
popup = monster.ui.dialog(popup_html, { | ||
title: self.i18n.active().numberPrepend.dialogTitle | ||
}); | ||
}, | ||
|
||
numberPrependGetNumber: function(phoneNumber, success, error) { | ||
var self = this; | ||
|
||
self.callApi({ | ||
resource: 'numbers.get', | ||
data: { | ||
accountId: self.accountId, | ||
phoneNumber: encodeURIComponent(phoneNumber) | ||
}, | ||
success: function(_data, status) { | ||
success && success(_data); | ||
}, | ||
error: function(_data, status) { | ||
error && error(_data); | ||
} | ||
}); | ||
}, | ||
|
||
numberPrependUpdateNumber: function(phoneNumber, data, success, error) { | ||
var self = this; | ||
|
||
self.callApi({ | ||
resource: 'numbers.update', | ||
data: { | ||
accountId: self.accountId, | ||
phoneNumber: encodeURIComponent(phoneNumber), | ||
data: data | ||
}, | ||
success: function(_data, status) { | ||
success && success(_data); | ||
}, | ||
error: function(_data, status) { | ||
error && error(_data); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
return numberPrepend; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="trunkstore_popup number-prepend clearfix"> | ||
<form id="number_prepend"> | ||
<div class="popup-content"> | ||
<label class="popup-label" for="number_prepend_value">{{ i18n.numberPrepend.title }}</label> | ||
<input type="text" id="number_prepend_value" name="name" value="{{name}}"/> | ||
<div class="help-box gray-box"> | ||
<div class="wrapper-icon"> | ||
<i class="icon-info-sign2"></i> | ||
</div> | ||
<div class="text-wrapper"> | ||
<p>{{ i18n.numberPrepend.help }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="popup-content popup-actions clearfix"> | ||
<div class="pull-right"> | ||
<a class="cancel-link monster-link blue" href="javascript:void(0);">{{ i18n.cancel }}</a> | ||
<button type="button" class="btn btn-success save">{{ i18n.saveChanges }}</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters