Newer JS syntax
This commit is contained in:
committed by
Emma L Garland
parent
65321e8f68
commit
da92c38dec
@@ -1,7 +1,7 @@
|
||||
angular.module("umbraco").controller("Umbraco.PrevalueEditors.CheckboxListController",
|
||||
angular.module("umbraco").controller("Umbraco.PrevalueEditors.CheckboxListController",
|
||||
function ($scope) {
|
||||
|
||||
var vm = this;
|
||||
const vm = this;
|
||||
|
||||
vm.configItems = [];
|
||||
vm.viewItems = [];
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
function init() {
|
||||
|
||||
var prevalues = ($scope.model.config ? $scope.model.config.prevalues : $scope.model.prevalues) || [];
|
||||
const prevalues = ($scope.model.config ? $scope.model.config.prevalues : $scope.model.prevalues) || [];
|
||||
|
||||
var items = [];
|
||||
let items = [];
|
||||
|
||||
for (var i = 0; i < prevalues.length; i++) {
|
||||
var item = {};
|
||||
for (let i = 0; i < prevalues.length; i++) {
|
||||
const item = {};
|
||||
|
||||
if (Utilities.isObject(prevalues[i])) {
|
||||
item.value = prevalues[i].value;
|
||||
@@ -42,10 +42,10 @@
|
||||
|
||||
vm.viewItems = [];
|
||||
|
||||
var iConfigItem;
|
||||
for (var i = 0; i < vm.configItems.length; i++) {
|
||||
let iConfigItem;
|
||||
for (let i = 0; i < vm.configItems.length; i++) {
|
||||
iConfigItem = vm.configItems[i];
|
||||
var isChecked = _.contains(newVal, iConfigItem.value);
|
||||
const isChecked = _.contains(newVal, iConfigItem.value);
|
||||
vm.viewItems.push({
|
||||
checked: isChecked,
|
||||
value: iConfigItem.value,
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
function change(model, value) {
|
||||
|
||||
var index = $scope.model.value.indexOf(value);
|
||||
const index = $scope.model.value.indexOf(value);
|
||||
|
||||
if (model === true) {
|
||||
//if it doesn't exist in the model, then add it
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
angular.module("umbraco").controller("Umbraco.PrevalueEditors.RadiobuttonListController",
|
||||
function ($scope) {
|
||||
|
||||
var vm = this;
|
||||
const vm = this;
|
||||
|
||||
vm.configItems = [];
|
||||
vm.viewItems = [];
|
||||
|
||||
function init() {
|
||||
|
||||
var prevalues = ($scope.model.config ? $scope.model.config.prevalues : $scope.model.prevalues) || [];
|
||||
const prevalues = ($scope.model.config ? $scope.model.config.prevalues : $scope.model.prevalues) || [];
|
||||
|
||||
var items = [];
|
||||
let items = [];
|
||||
|
||||
for (var i = 0; i < prevalues.length; i++) {
|
||||
var item = {};
|
||||
for (let i = 0; i < prevalues.length; i++) {
|
||||
const item = {};
|
||||
|
||||
if (Utilities.isObject(prevalues[i])) {
|
||||
item.value = prevalues[i].value;
|
||||
@@ -37,8 +37,8 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RadiobuttonListCon
|
||||
|
||||
vm.viewItems = [];
|
||||
|
||||
var iConfigItem;
|
||||
for (var i = 0; i < vm.configItems.length; i++) {
|
||||
let iConfigItem;
|
||||
for (let i = 0; i < vm.configItems.length; i++) {
|
||||
iConfigItem = vm.configItems[i];
|
||||
vm.viewItems.push({
|
||||
value: iConfigItem.value,
|
||||
|
||||
@@ -15,15 +15,16 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro
|
||||
if (Utilities.isObject($scope.model.config.items)) {
|
||||
|
||||
// formatting the items in the dictionary into an array
|
||||
var sortedItems = [];
|
||||
var vals = _.values($scope.model.config.items);
|
||||
var keys = _.keys($scope.model.config.items);
|
||||
let sortedItems = [];
|
||||
let vals = _.values($scope.model.config.items);
|
||||
let keys = _.keys($scope.model.config.items);
|
||||
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
sortedItems.push({ key: keys[i], sortOrder: vals[i].sortOrder, value: vals[i].value});
|
||||
}
|
||||
|
||||
// ensure the items are sorted by the provided sort order
|
||||
sortedItems.sort(function (a, b) { return (a.sortOrder > b.sortOrder) ? 1 : ((b.sortOrder > a.sortOrder) ? -1 : 0); });
|
||||
sortedItems.sort((a, b) => (a.sortOrder > b.sortOrder) ? 1 : ((b.sortOrder > a.sortOrder) ? -1 : 0) );
|
||||
|
||||
vm.configItems = sortedItems;
|
||||
|
||||
@@ -48,10 +49,10 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro
|
||||
|
||||
function updateViewModel(newVal) {
|
||||
|
||||
var i = vm.configItems.length;
|
||||
let i = vm.configItems.length;
|
||||
while(i--) {
|
||||
|
||||
var item = vm.configItems[i];
|
||||
const item = vm.configItems[i];
|
||||
|
||||
// are this item the same in the model
|
||||
if (item.checked !== (newVal.indexOf(item.value) !== -1)) {
|
||||
@@ -69,22 +70,21 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro
|
||||
|
||||
vm.viewItems = [];
|
||||
|
||||
var iConfigItem;
|
||||
for (var i = 0; i < vm.configItems.length; i++) {
|
||||
let iConfigItem;
|
||||
for (let i = 0; i < vm.configItems.length; i++) {
|
||||
iConfigItem = vm.configItems[i];
|
||||
var isChecked = _.contains(newVal, iConfigItem.value);
|
||||
const isChecked = _.contains(newVal, iConfigItem.value);
|
||||
vm.viewItems.push({
|
||||
checked: isChecked,
|
||||
key: iConfigItem.key,
|
||||
value: iConfigItem.value
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function change(model, value) {
|
||||
|
||||
var index = $scope.model.value.indexOf(value);
|
||||
const index = $scope.model.value.indexOf(value);
|
||||
|
||||
if (model === true) {
|
||||
//if it doesn't exist in the model, then add it
|
||||
|
||||
@@ -13,24 +13,25 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.RadioButtonsContro
|
||||
if (Utilities.isObject($scope.model.config.items)) {
|
||||
|
||||
// formatting the items in the dictionary into an array
|
||||
var sortedItems = [];
|
||||
var vals = _.values($scope.model.config.items);
|
||||
var keys = _.keys($scope.model.config.items);
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
let sortedItems = [];
|
||||
let vals = _.values($scope.model.config.items);
|
||||
let keys = _.keys($scope.model.config.items);
|
||||
|
||||
for (let i = 0; i < vals.length; i++) {
|
||||
sortedItems.push({ key: keys[i], sortOrder: vals[i].sortOrder, value: vals[i].value });
|
||||
}
|
||||
|
||||
// ensure the items are sorted by the provided sort order
|
||||
sortedItems.sort(function (a, b) { return (a.sortOrder > b.sortOrder) ? 1 : ((b.sortOrder > a.sortOrder) ? -1 : 0); });
|
||||
sortedItems.sort((a, b) => (a.sortOrder > b.sortOrder) ? 1 : ((b.sortOrder > a.sortOrder) ? -1 : 0) );
|
||||
|
||||
vm.viewItems = sortedItems;
|
||||
}
|
||||
|
||||
// Set the message to use for when a mandatory field isn't completed.
|
||||
// Will either use the one provided on the property type or a localised default.
|
||||
validationMessageService.getMandatoryMessage($scope.model.validation).then(function (value) {
|
||||
validationMessageService.getMandatoryMessage($scope.model.validation).then(value => {
|
||||
$scope.mandatoryMessage = value;
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user