fix start node pickers
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
vm.openMediaPicker = openMediaPicker;
|
||||
vm.openUserPicker = openUserPicker;
|
||||
vm.removeSelectedItem = removeSelectedItem;
|
||||
vm.clearStartNode = clearStartNode;
|
||||
vm.getUserStateType = getUserStateType;
|
||||
|
||||
function init() {
|
||||
@@ -64,11 +65,11 @@
|
||||
vm.contentPicker = {
|
||||
title: "Select content start node",
|
||||
view: "contentpicker",
|
||||
multiPicker: true,
|
||||
hideSubmitButton: true,
|
||||
show: true,
|
||||
submit: function(model) {
|
||||
if(model.selection) {
|
||||
vm.userGroup.startNodesContent = model.selection;
|
||||
vm.userGroup.startContentId = model.selection[0];
|
||||
}
|
||||
vm.contentPicker.show = false;
|
||||
vm.contentPicker = null;
|
||||
@@ -87,11 +88,11 @@
|
||||
section: "media",
|
||||
treeAlias: "media",
|
||||
entityType: "media",
|
||||
multiPicker: true,
|
||||
hideSubmitButton: true,
|
||||
show: true,
|
||||
submit: function(model) {
|
||||
if(model.selection) {
|
||||
vm.userGroup.startNodesMedia = model.selection;
|
||||
vm.userGroup.startMediaId = model.selection[0];
|
||||
}
|
||||
vm.contentPicker.show = false;
|
||||
vm.contentPicker = null;
|
||||
@@ -126,7 +127,17 @@
|
||||
}
|
||||
|
||||
function removeSelectedItem(index, selection) {
|
||||
selection.splice(index, 1);
|
||||
if(selection && selection.length > 0) {
|
||||
selection.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function clearStartNode(type) {
|
||||
if (type === "content") {
|
||||
vm.userGroup.startContentId = null;
|
||||
} else if (type === "media") {
|
||||
vm.userGroup.startMediaId = null;
|
||||
}
|
||||
}
|
||||
|
||||
function getUserStateType(state) {
|
||||
|
||||
@@ -44,17 +44,18 @@
|
||||
</a>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="Content start nodes" description="Lorem ipsum dolor sit amet, consectetur adipiscing elit.">
|
||||
<umb-control-group label="Content start node" description="Lorem ipsum dolor sit amet, consectetur adipiscing elit.">
|
||||
<umb-node-preview
|
||||
ng-if="vm.userGroup.startContentId.id"
|
||||
style="max-width: 100%;"
|
||||
ng-repeat="node in vm.userGroup.startNodesContent"
|
||||
icon="node.icon"
|
||||
name="node.name"
|
||||
icon="vm.userGroup.startContentId.icon"
|
||||
name="vm.userGroup.startContentId.name"
|
||||
allow-remove="true"
|
||||
on-remove="vm.removeSelectedItem($index, vm.userGroup.startNodesContent)">
|
||||
on-remove="vm.clearStartNode('content')">
|
||||
</umb-node-preview>
|
||||
|
||||
<a href=""
|
||||
ng-if="!vm.userGroup.startContentId.id"
|
||||
style="max-width: 100%;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()"
|
||||
@@ -63,17 +64,18 @@
|
||||
</a>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="Media start nodes" description="Donec quis lacinia ligula. Suspendisse ultrices risus ante">
|
||||
<umb-control-group label="Media start node" description="Donec quis lacinia ligula. Suspendisse ultrices risus ante">
|
||||
<umb-node-preview
|
||||
ng-if="vm.userGroup.startMediaId.id"
|
||||
style="max-width: 100%;"
|
||||
ng-repeat="node in vm.userGroup.startNodesMedia"
|
||||
icon="node.icon"
|
||||
name="node.name"
|
||||
icon="vm.userGroup.startMediaId.icon"
|
||||
name="vm.userGroup.startMediaId.name"
|
||||
allow-remove="true"
|
||||
on-remove="vm.removeSelectedItem($index, vm.userGroup.startNodesMedia)">
|
||||
on-remove="vm.clearStartNode('media')">
|
||||
</umb-node-preview>
|
||||
|
||||
<a href=""
|
||||
ng-if="!vm.userGroup.startMediaId.id"
|
||||
style="max-width: 100%;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openMediaPicker()"
|
||||
|
||||
@@ -100,15 +100,21 @@
|
||||
title: "Select content start node",
|
||||
view: "contentpicker",
|
||||
multiPicker: true,
|
||||
selection: vm.user.startContentIds,
|
||||
show: true,
|
||||
submit: function (model) {
|
||||
// select items
|
||||
if (model.selection) {
|
||||
vm.user.startNodesContent = model.selection;
|
||||
angular.forEach(model.selection, function(item){
|
||||
multiSelectItem(item, vm.user.startContentIds);
|
||||
});
|
||||
}
|
||||
// close overlay
|
||||
vm.contentPicker.show = false;
|
||||
vm.contentPicker = null;
|
||||
},
|
||||
close: function (oldModel) {
|
||||
// close overlay
|
||||
vm.contentPicker.show = false;
|
||||
vm.contentPicker = null;
|
||||
}
|
||||
@@ -125,19 +131,40 @@
|
||||
multiPicker: true,
|
||||
show: true,
|
||||
submit: function (model) {
|
||||
// select items
|
||||
if (model.selection) {
|
||||
vm.user.startNodesMedia = model.selection;
|
||||
angular.forEach(model.selection, function(item){
|
||||
multiSelectItem(item, vm.user.startMediaIds);
|
||||
});
|
||||
}
|
||||
// close overlay
|
||||
vm.mediaPicker.show = false;
|
||||
vm.mediaPicker = null;
|
||||
},
|
||||
close: function (oldModel) {
|
||||
// close overlay
|
||||
vm.mediaPicker.show = false;
|
||||
vm.mediaPicker = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function multiSelectItem(item, selection) {
|
||||
var found = false;
|
||||
// check if item is already in the selected list
|
||||
if (selection.length > 0) {
|
||||
angular.forEach(selection, function (selectedItem) {
|
||||
if (selectedItem.udi === item.udi) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
// only add the selected item if it is not already selected
|
||||
if (!found) {
|
||||
selection.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
function removeSelectedItem(index, selection) {
|
||||
selection.splice(index, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user