Skip to content

Commit

Permalink
Added TODO notes to replace AngularJS functions
Browse files Browse the repository at this point in the history
This, in part, is due to an Umbraco issue about reliance on
AngularJS functions, and the effort involved in future decoupling.

umbraco/Umbraco-CMS#7718
https://trello.com/b/wiDsUbly/umbracos-angularjs-divorce

By getting into the mindset of agnostic JS functions (where applicable),
the code will (hopefully) be more portable (migratable).
  • Loading branch information
leekelleher committed Mar 2, 2020
1 parent ab28c1b commit 6c32bb5
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
items: [],
enableMultiple: 0
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -33,7 +33,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.model.value.splice(1);
}

vm.items = angular.copy(config.items);
vm.items = angular.copy(config.items); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

_.each(vm.items, function (item) {
item.selected = _.contains($scope.model.value, item.value);
Expand Down
6 changes: 3 additions & 3 deletions src/Umbraco.Community.Contentment/DataEditors/Cards/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
overlayOrderBy: "name",
enableDevMode: 0,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down Expand Up @@ -96,7 +96,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
submit: function (selectedItems) {

_.each(selectedItems, function (x) {
vm.items.push(angular.copy(x));
vm.items.push(angular.copy(x)); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
$scope.model.value.push(x.value);
});

Expand Down Expand Up @@ -126,7 +126,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
_.each($scope.model.value, function (v) {
var item = _.find(config.items, function (x) { return x.value === v });
if (item) {
vm.items.push(angular.copy(item));
vm.items.push(angular.copy(item)); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
} else {
orphaned.push(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
apis: [],
defaultValue: [""]
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
//console.log("checkbox.model", $scope.model);

var defaultConfig = { showInline: 0, defaultValue: 0 };
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
showIcons: 0,
defaultValue: []
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -27,7 +27,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.model.value = [$scope.model.value];
}

vm.items = angular.copy(config.items);
vm.items = angular.copy(config.items); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

_.each(vm.items, function (item) {
item.checked = _.contains($scope.model.value, item.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
enableLiveAutocompletion: 0,
readonly: 0,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
var defaultConfig = {
editor: {}
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

function init() {

vm.editor = angular.copy(config.editor);
vm.editor = angular.copy(config.editor); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

$scope.model.value = $scope.model.value || { type: vm.editor.type, value: vm.editor.defaultValues || {} };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
overlayView: "",
enableDevMode: 0,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
enableFilter: false,
orderBy: "name"
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down Expand Up @@ -62,7 +62,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
}

vm.title = "Configure " + editor.name;
vm.editor = angular.copy(editor);
vm.editor = angular.copy(editor); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

if (vm.editor.fields && vm.editor.fields.length > 0) {
_.each(vm.editor.fields, function (x) {
Expand Down Expand Up @@ -96,7 +96,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
// https://github.com/umbraco/Umbraco-CMS/blob/release-8.1.0/src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js#L26
$scope.$broadcast("formSubmitting", { scope: $scope });

var obj = angular.extend({ value: {} }, item);
var obj = angular.extend({ value: {} }, item); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

_.each(item.fields, function (x) {
obj.value[x.key] = x.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
overlayView: "",
enableDevMode: 0,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down Expand Up @@ -296,7 +296,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
expireDate: null,
releaseDate: null,
templateAlias: null,
variants: [angular.extend({ save: true }, variant)]
variants: [angular.extend({ save: true }, variant)] // TODO: Replace AngularJS dependency. [LK:2020-03-02]
};

contentResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
elementTypes: [],
enableFilter: true,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down Expand Up @@ -112,7 +112,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
: contentResource.getScaffold(-2, elementType.alias);

getScaffold.then(function (data) {
angular.extend(vm.content, data.variants[0]);
angular.extend(vm.content, data.variants[0]); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
vm.loading = false;
});

Expand Down Expand Up @@ -158,7 +158,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Con
}
}

angular.extend(vm.content, data.variants[0]);
angular.extend(vm.content, data.variants[0]); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
vm.loading = false;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("datatable.model", $scope.model);

var defaultConfig = { fields: [], disableSorting: 0, maxItems: 0, restrictWidth: 0, usePrevalueEditors: 1 };
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -22,7 +22,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
vm.items = [];

_.each($scope.model.value, function (value, row) {
var fields = angular.copy(config.fields);
var fields = angular.copy(config.fields); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

_.each(fields, function (field, cell) {
field.alias = [$scope.model.alias, row, cell].join("_");
Expand Down Expand Up @@ -72,7 +72,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
};

function add() {
vm.items.push(angular.copy(config.fields));
vm.items.push(angular.copy(config.fields)); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

if ((config.maxItems !== 0 && config.maxItems !== "0") && vm.items.length >= config.maxItems) {
vm.allowAdd = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
defaultValue: "",
htmlAttributes: []
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -26,7 +26,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.model.value = _.first($scope.model.value);
}

vm.items = angular.copy(config.items);
vm.items = angular.copy(config.items); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

vm.allowEmpty = Object.toBoolean(config.allowEmpty);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("icon-picker.model", $scope.model);

var defaultConfig = { defaultIcon: "", size: "large" };
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
overlayOrderBy: "name",
enableDevMode: 0,
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down Expand Up @@ -90,7 +90,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
submit: function (selectedItems) {

_.each(selectedItems, function (x) {
vm.items.push(angular.copy(x));
vm.items.push(angular.copy(x)); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
$scope.model.value.push(x.value);
});

Expand Down Expand Up @@ -120,7 +120,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
_.each($scope.model.value, function (v) {
var item = _.find(config.items, function (x) { return x.value === v });
if (item) {
vm.items.push(angular.copy(item));
vm.items.push(angular.copy(item)); // TODO: Replace AngularJS dependency. [LK:2020-03-02]
} else {
orphaned.push(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.Overlays.Ite
listType: "grid",
orderBy: "name",
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
maxItems: 0,
disableSorting: 0
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
showIcons: 0,
defaultValue: ""
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -26,7 +26,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.model.value = _.first($scope.model.value);
}

vm.items = angular.copy(config.items);
vm.items = angular.copy(config.items); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

vm.showDescriptions = Object.toBoolean(config.showDescriptions);
vm.showIcons = Object.toBoolean(config.showIcons);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

var macro = _.first($scope.model.config.macro);

angular.extend(macro.params, {
angular.extend(macro.params, { // TODO: Replace AngularJS dependency. [LK:2020-03-02]
"__propertyAlias": $scope.model.alias,
"__propertyLabel": $scope.model.label,
"__propertyCulture": $scope.model.culture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
append: null,
maxChars: 500
};
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
// console.log("toggles.model", $scope.model);

var defaultConfig = { items: [], showDescriptions: 1, defaultValue: [] };
var config = angular.extend({}, defaultConfig, $scope.model.config);
var config = angular.extend({}, defaultConfig, $scope.model.config); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var vm = this;

Expand All @@ -21,7 +21,7 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.model.value = [$scope.model.value];
}

vm.items = angular.copy(config.items);
vm.items = angular.copy(config.items); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

var removeDescriptions = Object.toBoolean(config.showDescriptions) == false;

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Community.Contentment/DataEditors/_/_dev-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module("umbraco.services").factory("Umbraco.Community.Contentment.Servic
editValue: function (model, callback) {
editorService.open({
title: "Edit raw value",
value: angular.toJson(model.value, true),
value: angular.toJson(model.value, true), // TODO: Replace AngularJS dependency. [LK:2020-03-02]
ace: {
showGutter: true,
useWrapMode: true,
Expand All @@ -26,7 +26,7 @@ angular.module("umbraco.services").factory("Umbraco.Community.Contentment.Servic
size: "small",
submit: function (value) {

model.value = angular.fromJson(value);
model.value = angular.fromJson(value); // TODO: Replace AngularJS dependency. [LK:2020-03-02]

if (callback) {
callback();
Expand Down

0 comments on commit 6c32bb5

Please sign in to comment.