Initial commit: apps.supersamsev.ru
This commit is contained in:
commit
a4ad79309c
17298 files changed
+1746593
No files matched your search
@@ -0,0 +1,713 @@
|
||||
var UtilitiesClass;
|
||||
|
||||
(function(module) {
|
||||
module.directive('clickPrevent', function() {
|
||||
return function(scope, element) {
|
||||
return element.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
return e.stopPropagation();
|
||||
});
|
||||
};
|
||||
});
|
||||
module.directive('ngEnter', function() {
|
||||
return function(scope, element, attrs) {
|
||||
return element.bind("keydown keypress", function(event) {
|
||||
if (event.which === 13) {
|
||||
scope.$apply(function() {
|
||||
return scope.$eval(attrs.ngEnter);
|
||||
});
|
||||
return event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
module.directive('digitsOnly', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attrs, modelCtrl) {
|
||||
modelCtrl.$parsers.push(function(inputValue) {
|
||||
var transformedInput;
|
||||
if (inputValue && (typeof inputValue !== "String")) {
|
||||
inputValue = inputValue.toString();
|
||||
}
|
||||
transformedInput = inputValue ? inputValue.replace(/[^\d]/g, '') : null;
|
||||
if (transformedInput !== inputValue) {
|
||||
modelCtrl.$setViewValue(transformedInput);
|
||||
modelCtrl.$render();
|
||||
}
|
||||
return transformedInput;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
module.directive('numbersOnly', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attrs, modelCtrl) {
|
||||
modelCtrl.$parsers.push(function(inputValue) {
|
||||
var transformedInput;
|
||||
if (inputValue && (typeof inputValue !== "String")) {
|
||||
inputValue = inputValue.toString();
|
||||
}
|
||||
transformedInput = inputValue ? inputValue.replace(/[^\d.]/g, '') : null;
|
||||
if (transformedInput !== inputValue) {
|
||||
modelCtrl.$setViewValue(transformedInput);
|
||||
modelCtrl.$render();
|
||||
}
|
||||
return transformedInput;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
module.directive('floatingNumberOnly', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, ele, attr, ctrl) {
|
||||
ctrl.$parsers.push(function(inputValue) {
|
||||
var dotCount, dotPattern, newInput, newInputLength, pattern, result;
|
||||
pattern = new RegExp('(^[0-9]{1,9})+(.[0-9]{1,2})?$', 'g');
|
||||
if (inputValue === '') {
|
||||
return '';
|
||||
}
|
||||
dotPattern = /^[.]*$/;
|
||||
if (dotPattern.test(inputValue)) {
|
||||
ctrl.$setViewValue('');
|
||||
ctrl.$render();
|
||||
return '';
|
||||
}
|
||||
newInput = inputValue.replace(/[^0-9.]/g, '');
|
||||
if (newInput !== inputValue) {
|
||||
ctrl.$setViewValue(newInput);
|
||||
ctrl.$render();
|
||||
}
|
||||
result = void 0;
|
||||
dotCount = void 0;
|
||||
newInputLength = newInput.length;
|
||||
if (result = pattern.test(newInput)) {
|
||||
dotCount = newInput.split('.').length - 1;
|
||||
if (dotCount === 0 && newInputLength > 9) {
|
||||
newInput = newInput.slice(0, newInputLength - 1);
|
||||
ctrl.$setViewValue(newInput);
|
||||
ctrl.$render();
|
||||
}
|
||||
} else {
|
||||
dotCount = newInput.split('.').length - 1;
|
||||
if (newInputLength > 0 && dotCount > 1) {
|
||||
newInput = newInput.slice(0, newInputLength - 1);
|
||||
}
|
||||
if (newInput.slice(newInput.indexOf('.') + 1).length > 2) {
|
||||
newInput = newInput.slice(0, newInputLength - 1);
|
||||
}
|
||||
ctrl.$setViewValue(newInput);
|
||||
ctrl.$render();
|
||||
}
|
||||
return newInput;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
module.directive('inputMask', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, elem, attr, ctrl) {
|
||||
if (attr.inputMask) {
|
||||
elem.mask(attr.inputMask);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
module.filter('trustAs', [
|
||||
'$sce',
|
||||
function($sce) {
|
||||
return function(input,
|
||||
type) {
|
||||
if (typeof input === 'string') {
|
||||
return $sce.trustAs(type || 'html',
|
||||
input);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
}
|
||||
]);
|
||||
module.config(function($provide) {
|
||||
$provide.decorator('$http', function($delegate, $q) {
|
||||
$delegate.with_abort = function(options) {
|
||||
var abort_defer, do_throw_error, http_promise, mod_promise, new_options, real_then, then_function;
|
||||
abort_defer = $q.defer();
|
||||
new_options = angular.copy(options);
|
||||
new_options.timeout = abort_defer.promise;
|
||||
do_throw_error = false;
|
||||
mod_promise = function(promise) {
|
||||
promise.then = then_function;
|
||||
promise.abort = function(do_throw_error_param = false) {
|
||||
do_throw_error = do_throw_error_param;
|
||||
abort_defer.resolve();
|
||||
};
|
||||
return promise;
|
||||
};
|
||||
http_promise = $delegate(new_options).then((function(response) {
|
||||
return response;
|
||||
}), function(error) {
|
||||
if (do_throw_error) {
|
||||
return $q.reject(error);
|
||||
}
|
||||
return $q(function() {
|
||||
return null;
|
||||
});
|
||||
});
|
||||
// prevent promise chain propagation
|
||||
real_then = http_promise.then;
|
||||
then_function = function() {
|
||||
return mod_promise(real_then.apply(this, arguments));
|
||||
};
|
||||
return mod_promise(http_promise);
|
||||
};
|
||||
return $delegate;
|
||||
});
|
||||
});
|
||||
module.factory('HttpInterceptor', [
|
||||
'$q',
|
||||
'$timeout',
|
||||
function($q,
|
||||
$timeout) {
|
||||
return {
|
||||
responseError: function(rejection) {
|
||||
if (rejection.status === 403) {
|
||||
toastr.warning("Пользователь не авторизован!");
|
||||
$timeout(() => {
|
||||
return window.location.href = "/manager/login";
|
||||
},
|
||||
1200);
|
||||
return $q(() => {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return $q.reject(rejection);
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
module.filter('orderObjectBy', function() {
|
||||
return function(data, order) {
|
||||
var items, objectKey;
|
||||
if (!angular.isObject(data)) {
|
||||
return data;
|
||||
}
|
||||
items = [];
|
||||
for (objectKey in data) {
|
||||
if (data.hasOwnProperty(objectKey)) {
|
||||
items.push(data[objectKey]);
|
||||
}
|
||||
}
|
||||
items.sort(function(a, b) {
|
||||
var tmpa, tmpb;
|
||||
tmpa = a[order.field];
|
||||
tmpb = b[order.field];
|
||||
if (tmpa > tmpb) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
if (order.reverse) {
|
||||
items.reverse();
|
||||
}
|
||||
return items;
|
||||
};
|
||||
});
|
||||
return module.filter('filterData', function() {
|
||||
return function(items, filter) {
|
||||
var filtered, searchTranslatedToEng, searchTranslatedToRus, searches;
|
||||
filtered = [];
|
||||
if (filter && (filter.length > 0)) {
|
||||
searches = [filter.toLowerCase()];
|
||||
searchTranslatedToRus = replaceToRus(searches[0]);
|
||||
searchTranslatedToEng = replaceToEng(searches[0]);
|
||||
if (searchTranslatedToRus !== searches[0]) {
|
||||
searches.push(escapeRegExp(searchTranslatedToRus));
|
||||
}
|
||||
if (searchTranslatedToEng !== searches[0]) {
|
||||
searches.push(escapeRegExp(searchTranslatedToEng));
|
||||
}
|
||||
searches[0] = escapeRegExp(searches[0]);
|
||||
filtered = [];
|
||||
angular.forEach(items, function(item) {
|
||||
var i, itemFiltered, len, results, search;
|
||||
itemFiltered = false;
|
||||
results = [];
|
||||
for (i = 0, len = searches.length; i < len; i++) {
|
||||
search = searches[i];
|
||||
if (!itemFiltered) {
|
||||
if (item.label && item.label.toLowerCase().match(search) || item.color && item.color.toLowerCase().match(search) || item.profile && item.profile.toLowerCase().match(search)) {
|
||||
filtered.push(item);
|
||||
results.push(itemFiltered = true);
|
||||
} else {
|
||||
results.push(void 0);
|
||||
}
|
||||
} else {
|
||||
results.push(void 0);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
});
|
||||
} else {
|
||||
filtered = items;
|
||||
}
|
||||
return filtered;
|
||||
};
|
||||
});
|
||||
})(supersamApp);
|
||||
|
||||
UtilitiesClass = class UtilitiesClass {
|
||||
constructor(config, $filter = null, $timeout, $http = null) {
|
||||
this.getLastUpdate = this.getLastUpdate.bind(this);
|
||||
this.getYesNoLabel = this.getYesNoLabel.bind(this);
|
||||
this.setUpdateDates = this.setUpdateDates.bind(this);
|
||||
this.getBorderImageById = this.getBorderImageById.bind(this);
|
||||
this.getFasadBorderImageById = this.getFasadBorderImageById.bind(this);
|
||||
this.getDoorImageById = this.getDoorImageById.bind(this);
|
||||
this.getSheetImageById = this.getSheetImageById.bind(this);
|
||||
this.getFasadSheetImageById = this.getFasadSheetImageById.bind(this);
|
||||
this.showContentOnLoad = this.showContentOnLoad.bind(this);
|
||||
this.getBranchNameById = this.getBranchNameById.bind(this);
|
||||
this.isAppAvailableToUser = this.isAppAvailableToUser.bind(this);
|
||||
this.addAppAvailableToUser = this.addAppAvailableToUser.bind(this);
|
||||
this.removeAppAvailableToUser = this.removeAppAvailableToUser.bind(this);
|
||||
this.getConfigLabel = this.getConfigLabel.bind(this);
|
||||
this.getDoorManufacturer = this.getDoorManufacturer.bind(this);
|
||||
this.getUserNameById = this.getUserNameById.bind(this);
|
||||
this.getCreatedForUserNameById = this.getCreatedForUserNameById.bind(this);
|
||||
this.getAvailableToOrderManagerNameById = this.getAvailableToOrderManagerNameById.bind(this);
|
||||
this.formatFileSize = this.formatFileSize.bind(this);
|
||||
this.getSelectedSheetsInStock = this.getSelectedSheetsInStock.bind(this);
|
||||
this.sortBy = this.sortBy.bind(this);
|
||||
this.getSortByClass = this.getSortByClass.bind(this);
|
||||
this.getSortParams = this.getSortParams.bind(this);
|
||||
this.getSmsStatusClass = this.getSmsStatusClass.bind(this);
|
||||
this.getPaymentStatusClass = this.getPaymentStatusClass.bind(this);
|
||||
this.getSmsRuBalance = this.getSmsRuBalance.bind(this);
|
||||
this.config = config;
|
||||
this.filter = $filter;
|
||||
this.timeout = $timeout;
|
||||
this.http = $http;
|
||||
this.smsRuBalance = null;
|
||||
this.smsRuBalanceIsLoading = false;
|
||||
this.smsRuBalanceIsLoaded = false;
|
||||
}
|
||||
|
||||
getLastUpdate(app = "", group) {
|
||||
var configField, i, label, len, ref, ts, user, v;
|
||||
label = "";
|
||||
configField = "updates";
|
||||
if (app !== "") {
|
||||
configField = app + "_" + configField;
|
||||
}
|
||||
if (this.config[configField] && this.config[configField][group + 'LastUpdateDate']) {
|
||||
ts = new Date(this.config[configField][group + 'LastUpdateDate'].value * 1000);
|
||||
label = 'Последнее обновление ' + this.filter('date')(ts, 'dd-MM-yyyy в HH:mm');
|
||||
if (this.config[configField][group + 'LastUpdateManagerId']) {
|
||||
ref = this.config.users;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === parseInt(this.config[configField][group + 'LastUpdateManagerId'].value)) {
|
||||
user = v;
|
||||
}
|
||||
}
|
||||
if (user) {
|
||||
label += " пользователем " + user.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
getYesNoLabel(data) {
|
||||
if (data === true) {
|
||||
return 'Да';
|
||||
} else {
|
||||
return 'Нет';
|
||||
}
|
||||
}
|
||||
|
||||
setUpdateDates(group, data, updates) {
|
||||
if (data[group + 'LastUpdateDate']) {
|
||||
if (!updates[group + 'LastUpdateDate']) {
|
||||
updates[group + 'LastUpdateDate'] = {};
|
||||
}
|
||||
if (!updates[group + 'LastUpdateManagerId']) {
|
||||
updates[group + 'LastUpdateManagerId'] = {};
|
||||
}
|
||||
updates[group + 'LastUpdateDate'].value = angular.copy(data[group + 'LastUpdateDate']);
|
||||
return updates[group + 'LastUpdateManagerId'].value = angular.copy(data[group + 'LastUpdateManagerId']);
|
||||
}
|
||||
}
|
||||
|
||||
getBorderImageById(borderId) {
|
||||
var i, image, len, ref, selectedBorder, v;
|
||||
image = '';
|
||||
if (borderId) {
|
||||
ref = this.config.borders;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === borderId) {
|
||||
selectedBorder = v;
|
||||
}
|
||||
}
|
||||
if (selectedBorder && selectedBorder.image) {
|
||||
image = '/img/borders/' + selectedBorder.image;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
getFasadBorderImageById(borderId) {
|
||||
var i, image, len, ref, selectedBorder, v;
|
||||
image = '';
|
||||
if (borderId) {
|
||||
ref = this.config.borders;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === borderId) {
|
||||
selectedBorder = v;
|
||||
}
|
||||
}
|
||||
if (selectedBorder && selectedBorder.image) {
|
||||
image = '/img/fasad_borders/' + selectedBorder.image;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
getDoorImageById(doorId) {
|
||||
var i, image, len, ref, selectedDoor, v;
|
||||
image = '';
|
||||
if (doorId) {
|
||||
ref = this.config.doors;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === doorId) {
|
||||
selectedDoor = v;
|
||||
}
|
||||
}
|
||||
if (selectedDoor) {
|
||||
if (selectedDoor.image) {
|
||||
image = '/img/doors/' + selectedDoor.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
getSheetImageById(sheetId, type = 'image') {
|
||||
var i, image, len, ref, selectedSheet, v;
|
||||
image = '';
|
||||
if (sheetId) {
|
||||
ref = this.config.sheets;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === sheetId) {
|
||||
selectedSheet = v;
|
||||
}
|
||||
}
|
||||
if (selectedSheet) {
|
||||
if (type === 'image') {
|
||||
if (selectedSheet.image) {
|
||||
image = '/img/sheets/' + selectedSheet.image;
|
||||
}
|
||||
} else {
|
||||
if (selectedSheet.thumb) {
|
||||
image = '/img/sheet_thumbs/' + selectedSheet.thumb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
getFasadSheetImageById(sheetId, type = 'image') {
|
||||
var i, image, len, ref, selectedSheet, v;
|
||||
image = '';
|
||||
if (sheetId) {
|
||||
ref = this.config.sheets;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === sheetId) {
|
||||
selectedSheet = v;
|
||||
}
|
||||
}
|
||||
if (selectedSheet) {
|
||||
if (type === 'image') {
|
||||
if (selectedSheet.image) {
|
||||
image = '/img/fasad_sheets/' + selectedSheet.image;
|
||||
}
|
||||
} else {
|
||||
if (selectedSheet.thumb) {
|
||||
image = '/img/fasad_sheet_thumbs/' + selectedSheet.thumb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
showContentOnLoad() {
|
||||
return this.timeout(() => {
|
||||
return angular.element('.hidden-on-load').removeClass('hidden-on-load');
|
||||
});
|
||||
}
|
||||
|
||||
getBranchNameById(branchId) {
|
||||
var branch, i, len, ref, selectedBranch, v;
|
||||
branch = '';
|
||||
if (branchId) {
|
||||
ref = this.config.branches;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === branchId) {
|
||||
selectedBranch = v;
|
||||
}
|
||||
}
|
||||
if (selectedBranch && selectedBranch.label) {
|
||||
branch = selectedBranch.label;
|
||||
}
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
|
||||
isAppAvailableToUser(availableApps, appId) {
|
||||
var result;
|
||||
result = false;
|
||||
if (availableApps && (availableApps.indexOf(appId) !== -1)) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
addAppAvailableToUser(user, appId, isDisabled) {
|
||||
if (isDisabled) {
|
||||
return;
|
||||
}
|
||||
if (!user.available_apps) {
|
||||
user.available_apps = [];
|
||||
}
|
||||
if (user.available_apps.indexOf(appId) < 0) {
|
||||
return user.available_apps.push(appId);
|
||||
}
|
||||
}
|
||||
|
||||
removeAppAvailableToUser(user, appId, isDisabled) {
|
||||
var pos;
|
||||
if (isDisabled) {
|
||||
return;
|
||||
}
|
||||
if (!user.available_apps) {
|
||||
user.available_apps = [];
|
||||
}
|
||||
if (user.available_apps.length > 1) {
|
||||
pos = user.available_apps.indexOf(appId);
|
||||
if (pos !== -1) {
|
||||
return user.available_apps.splice(pos, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getConfigLabel(key, global = false) {
|
||||
var label;
|
||||
label = '';
|
||||
if (!global) {
|
||||
if (this.config.labels[key]) {
|
||||
label = this.config.labels[key].value;
|
||||
}
|
||||
} else {
|
||||
if (this.config.global_labels[key]) {
|
||||
label = this.config.global_labels[key].value;
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
getDoorManufacturer(manufacturerId) {
|
||||
var key, label, manufacturer, ref;
|
||||
label = '';
|
||||
if (manufacturerId) {
|
||||
ref = this.config.doorsManufacturers;
|
||||
for (key in ref) {
|
||||
manufacturer = ref[key];
|
||||
if (manufacturer.id === manufacturerId) {
|
||||
label = manufacturer.label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
getUserNameById(id) {
|
||||
var i, label, len, ref, user, v;
|
||||
label = "";
|
||||
ref = this.config.users;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === parseInt(id)) {
|
||||
user = v;
|
||||
}
|
||||
}
|
||||
if (user) {
|
||||
label = user.name;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
getCreatedForUserNameById(id) {
|
||||
var i, label, len, ref, user, v;
|
||||
label = "";
|
||||
ref = this.config.users;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === parseInt(id)) {
|
||||
user = v;
|
||||
}
|
||||
}
|
||||
if (user) {
|
||||
label = user.availableToOrderName;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
getAvailableToOrderManagerNameById(id) {
|
||||
var i, label, len, ref, user, v;
|
||||
label = "";
|
||||
ref = this.config.availableToOrderManagers;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === parseInt(id)) {
|
||||
user = v;
|
||||
}
|
||||
}
|
||||
if (user) {
|
||||
label = user.name;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
formatFileSize(bytes) {
|
||||
var thresh, u, units;
|
||||
thresh = 1024;
|
||||
if (Math.abs(bytes) < thresh) {
|
||||
return bytes + ' B';
|
||||
}
|
||||
units = ['KB', 'MB'];
|
||||
u = -1;
|
||||
while (true) {
|
||||
bytes /= thresh;
|
||||
++u;
|
||||
if (!(Math.abs(bytes) >= thresh && u < units.length - 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bytes.toFixed(u > 0 ? u + 1 : 0) + ' ' + units[u];
|
||||
}
|
||||
|
||||
getSelectedSheetsInStock(sheetId) {
|
||||
var i, len, ref, result, selectedSheet, v;
|
||||
result = null;
|
||||
if (sheetId) {
|
||||
ref = this.config.sheets;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === sheetId) {
|
||||
selectedSheet = v;
|
||||
}
|
||||
}
|
||||
if (selectedSheet.quantityIn1C) {
|
||||
result = parseInt(selectedSheet.quantityIn1C);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
sortBy(group, field, defaultDirectionForField = 'asc') {
|
||||
if (this.config.sortFields[group].field === field) {
|
||||
this.config.sortFields[group].direction = angular.copy((this.config.sortFields[group].direction === 'desc' ? 'asc' : 'desc'));
|
||||
} else {
|
||||
this.config.sortFields[group].direction = angular.copy(defaultDirectionForField);
|
||||
}
|
||||
return this.config.sortFields[group].field = angular.copy(field);
|
||||
}
|
||||
|
||||
getSortByClass(group, field) {
|
||||
var result;
|
||||
result = "";
|
||||
if (this.config.sortFields[group].field === field) {
|
||||
result = this.config.sortFields[group].direction;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
getSortParams(group) {
|
||||
var currSortDirection;
|
||||
currSortDirection = ((this.config.sortFields[group].direction === "asc") ? false : true);
|
||||
return {
|
||||
reverse: currSortDirection,
|
||||
field: this.config.sortFields[group].field
|
||||
};
|
||||
}
|
||||
|
||||
getSmsStatusClass(status) {
|
||||
var result;
|
||||
result = "";
|
||||
if (status && (status.length > 0) && this.config.smsStatusList[status] && this.config.smsStatusList[status].class) {
|
||||
result = this.config.smsStatusList[status].class;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
getPaymentStatusClass(status) {
|
||||
var result;
|
||||
result = "";
|
||||
if (status && (status.length > 0) && this.config.paymentStatusList[status] && this.config.paymentStatusList[status].class) {
|
||||
result = this.config.paymentStatusList[status].class;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
getSmsRuBalance() {
|
||||
if (this.config.isAdmin && !this.smsRuBalanceIsLoading) {
|
||||
this.smsRuBalanceIsLoading = true;
|
||||
return this.http({
|
||||
method: 'POST',
|
||||
url: this.config.urls.subscribes,
|
||||
data: {
|
||||
action: 'getSmsRuBalance'
|
||||
},
|
||||
timeout: 30000
|
||||
}).then((response) => {
|
||||
var data, error, i, len, ref, results;
|
||||
this.smsRuBalanceIsLoading = false;
|
||||
if (response.data) {
|
||||
data = response.data;
|
||||
if (data.status && (data.status === "success")) {
|
||||
this.smsRuBalanceIsLoaded = true;
|
||||
return this.smsRuBalance = data.balance;
|
||||
} else {
|
||||
if (data.errors && data.errors.length) {
|
||||
ref = data.errors;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
error = ref[i];
|
||||
results.push(toastr.error(error));
|
||||
}
|
||||
return results;
|
||||
} else {
|
||||
return toastr.error(this.config.global_labels.defaultErrorMessage.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
this.smsRuBalanceIsLoading = false;
|
||||
return toastr.error('Произошла ошибка при запросе баланса, повторите позднее!');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user