Gets packaging scripts and partial views working and fixes packaging stylesheets and cleans things up a bit.
This commit is contained in:
@@ -1,401 +1,443 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, packageResource, editorService, formHelper, localizationService) {
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, packageResource, editorService, formHelper, localizationService) {
|
||||
|
||||
const vm = this;
|
||||
const vm = this;
|
||||
|
||||
const packageId = $routeParams.id;
|
||||
const create = $routeParams.create;
|
||||
const packageId = $routeParams.id;
|
||||
const create = $routeParams.create;
|
||||
|
||||
vm.showBackButton = true;
|
||||
vm.showBackButton = true;
|
||||
|
||||
// open all expansion panels
|
||||
vm.loading = true;
|
||||
vm.mediaNodeDisplayModels = [];
|
||||
vm.back = back;
|
||||
vm.createOrUpdatePackage = createOrUpdatePackage;
|
||||
vm.removeContentItem = removeContentItem;
|
||||
vm.openContentPicker = openContentPicker;
|
||||
vm.openViewPicker = openViewPicker;
|
||||
vm.removePackageView = removePackageView;
|
||||
vm.downloadFile = downloadFile;
|
||||
// open all expansion panels
|
||||
vm.loading = true;
|
||||
vm.mediaNodeDisplayModels = [];
|
||||
vm.back = back;
|
||||
vm.createOrUpdatePackage = createOrUpdatePackage;
|
||||
vm.removeContentItem = removeContentItem;
|
||||
vm.openContentPicker = openContentPicker;
|
||||
vm.openViewPicker = openViewPicker;
|
||||
vm.removePackageView = removePackageView;
|
||||
vm.downloadFile = downloadFile;
|
||||
|
||||
vm.selectDocumentType = selectDocumentType;
|
||||
vm.selectMediaType = selectMediaType;
|
||||
vm.selectTemplate = selectTemplate;
|
||||
vm.selectStyleSheet = selectStyleSheet;
|
||||
vm.selectMacro = selectMacro;
|
||||
vm.selectLanguage = selectLanguage;
|
||||
vm.selectDictionaryItem = selectDictionaryItem;
|
||||
vm.selectDataType = selectDataType;
|
||||
vm.selectDocumentType = selectDocumentType;
|
||||
vm.selectMediaType = selectMediaType;
|
||||
vm.selectTemplate = selectTemplate;
|
||||
vm.selectStyleSheet = selectStyleSheet;
|
||||
vm.selectScript = selectScript;
|
||||
vm.selectPartialView = selectPartialView;
|
||||
vm.selectMacro = selectMacro;
|
||||
vm.selectLanguage = selectLanguage;
|
||||
vm.selectDictionaryItem = selectDictionaryItem;
|
||||
vm.selectDataType = selectDataType;
|
||||
|
||||
vm.mediaPickerModel = {
|
||||
hideLabel: true,
|
||||
view: "mediapicker",
|
||||
value: "",
|
||||
config: {
|
||||
multiPicker: true,
|
||||
allowEdit:false
|
||||
}
|
||||
}
|
||||
vm.labels = {};
|
||||
|
||||
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
|
||||
|
||||
vm.aceOption = {
|
||||
mode: "xml",
|
||||
theme: "chrome",
|
||||
showPrintMargin: false,
|
||||
advanced: {
|
||||
fontSize: '14px',
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: false
|
||||
},
|
||||
onLoad: function (_editor) {
|
||||
vm.editor = _editor;
|
||||
|
||||
vm.editor.setValue(vm.package.actions);
|
||||
}
|
||||
};
|
||||
|
||||
function onInit() {
|
||||
|
||||
if (create) {
|
||||
// Pre populate package with some values
|
||||
packageResource.getEmpty().then(scaffold => {
|
||||
vm.package = scaffold;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
});
|
||||
|
||||
localizationService.localizeMany(["general_create", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
} else {
|
||||
// Load package
|
||||
packageResource.getCreatedById(packageId).then(createdPackage => {
|
||||
vm.package = createdPackage;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
|
||||
// Get render model for content node
|
||||
if (vm.package.contentNodeId) {
|
||||
entityResource.getById(vm.package.contentNodeId, "Document")
|
||||
.then((entity) => {
|
||||
vm.contentNodeDisplayModel = entity;
|
||||
});
|
||||
}
|
||||
|
||||
vm.mediaPickerModel.value = vm.package.mediaUdis.join(',');
|
||||
});
|
||||
|
||||
|
||||
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadResources() {
|
||||
|
||||
// Get all document types
|
||||
entityResource.getAll("DocumentType").then(documentTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
documentTypes.forEach(documentType => {
|
||||
documentType.id = documentType.id.toString();
|
||||
documentType.selected = vm.package.documentTypes.indexOf(documentType.id) !== -1;
|
||||
});
|
||||
vm.documentTypes = documentTypes;
|
||||
});
|
||||
|
||||
// Get all media types
|
||||
entityResource.getAll("MediaType").then(mediaTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
mediaTypes.forEach(mediaType => {
|
||||
mediaType.id = mediaType.id.toString();
|
||||
mediaType.selected = vm.package.mediaTypes.indexOf(mediaType.id) !== -1;
|
||||
});
|
||||
vm.mediaTypes = mediaTypes;
|
||||
});
|
||||
|
||||
// Get all templates
|
||||
entityResource.getAll("Template").then(templates => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
templates.forEach(template => {
|
||||
template.id = template.id.toString();
|
||||
template.selected = vm.package.templates.indexOf(template.id) >= 0;
|
||||
});
|
||||
vm.templates = templates;
|
||||
});
|
||||
|
||||
// Get all stylesheets
|
||||
entityResource.getAll("Stylesheet").then(stylesheets => {
|
||||
stylesheets.forEach(stylesheet => {
|
||||
stylesheet.selected = vm.package.stylesheets.indexOf(stylesheet.name) >= 0;
|
||||
});
|
||||
vm.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
// Get all macros
|
||||
entityResource.getAll("Macro").then(macros => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
macros.forEach(macro => {
|
||||
macro.id = macro.id.toString();
|
||||
macro.selected = vm.package.macros.indexOf(macro.id) !== -1;
|
||||
});
|
||||
vm.macros = macros;
|
||||
});
|
||||
|
||||
// Get all languages
|
||||
entityResource.getAll("Language").then(languages => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
languages.forEach(language => {
|
||||
language.id = language.id.toString();
|
||||
language.selected = vm.package.languages.indexOf(language.id) !== -1;
|
||||
});
|
||||
vm.languages = languages;
|
||||
});
|
||||
|
||||
// Get all dictionary items
|
||||
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dictionaryItems.forEach(dictionaryItem => {
|
||||
dictionaryItem.id = dictionaryItem.id.toString();
|
||||
dictionaryItem.selected = vm.package.dictionaryItems.indexOf(dictionaryItem.id) !== -1;
|
||||
});
|
||||
vm.dictionaryItems = dictionaryItems;
|
||||
});
|
||||
|
||||
// Get all data types
|
||||
entityResource.getAll("DataType").then(dataTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dataTypes.forEach(dataType => {
|
||||
dataType.id = dataType.id.toString();
|
||||
dataType.selected = vm.package.dataTypes.indexOf(dataType.id) !== -1;
|
||||
});
|
||||
vm.dataTypes = dataTypes;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function downloadFile(id) {
|
||||
var url = umbRequestHelper.getApiUrl(
|
||||
"packageApiBaseUrl",
|
||||
"DownloadCreatedPackage",
|
||||
{ id: id });
|
||||
|
||||
umbRequestHelper.downloadFile(url).then(function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function back() {
|
||||
$location.path("packages/packages/created").search("create", null).search("packageId", null);
|
||||
}
|
||||
|
||||
function createOrUpdatePackage(editPackageForm) {
|
||||
|
||||
// Split by comma and remove empty entries
|
||||
vm.package.mediaUdis = vm.mediaPickerModel.value.split(",").filter(i => i);
|
||||
if (formHelper.submitForm({ formCtrl: editPackageForm, scope: $scope })) {
|
||||
|
||||
vm.buttonState = "busy";
|
||||
|
||||
packageResource.savePackage(vm.package).then((updatedPackage) => {
|
||||
|
||||
vm.package = updatedPackage;
|
||||
vm.buttonState = "success";
|
||||
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm });
|
||||
|
||||
if (create) {
|
||||
//if we are creating, then redirect to the correct url and reload
|
||||
$location.path("packages/packages/edit/" + vm.package.id).search("create", null);
|
||||
//don't add a browser history for this
|
||||
$location.replace();
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm, hasErrors: true });
|
||||
formHelper.handleError(err);
|
||||
vm.buttonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeContentItem() {
|
||||
vm.package.contentNodeId = null;
|
||||
}
|
||||
|
||||
function openContentPicker() {
|
||||
const contentPicker = {
|
||||
submit: function (model) {
|
||||
if (model.selection && model.selection.length > 0) {
|
||||
vm.package.contentNodeId = model.selection[0].id.toString();
|
||||
vm.contentNodeDisplayModel = model.selection[0];
|
||||
}
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.contentPicker(contentPicker);
|
||||
vm.mediaPickerModel = {
|
||||
hideLabel: true,
|
||||
view: "mediapicker",
|
||||
value: "",
|
||||
config: {
|
||||
multiPicker: true,
|
||||
allowEdit: false
|
||||
}
|
||||
}
|
||||
vm.labels = {};
|
||||
|
||||
function openViewPicker() {
|
||||
const controlPicker = {
|
||||
title: "Select view",
|
||||
section: "settings",
|
||||
treeAlias: "files",
|
||||
entityType: "file",
|
||||
onlyInitialized: false,
|
||||
filter: function (i) {
|
||||
if (i.name.indexOf(".html") === -1 &&
|
||||
i.name.indexOf(".htm") === -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
filterCssClass: "not-allowed",
|
||||
select: function (node) {
|
||||
const id = decodeURIComponent(node.id.replace(/\+/g, " "));
|
||||
vm.package.packageView = id;
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.treePicker(controlPicker);
|
||||
}
|
||||
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
|
||||
|
||||
function removePackageView() {
|
||||
vm.package.packageView = null;
|
||||
}
|
||||
vm.aceOption = {
|
||||
mode: "xml",
|
||||
theme: "chrome",
|
||||
showPrintMargin: false,
|
||||
advanced: {
|
||||
fontSize: '14px',
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: false
|
||||
},
|
||||
onLoad: function (_editor) {
|
||||
vm.editor = _editor;
|
||||
|
||||
function selectDocumentType(doctype) {
|
||||
vm.editor.setValue(vm.package.actions);
|
||||
}
|
||||
};
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.documentTypes.indexOf(doctype.id);
|
||||
function onInit() {
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.documentTypes.push(doctype.id);
|
||||
} else {
|
||||
vm.package.documentTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
if (create) {
|
||||
// Pre populate package with some values
|
||||
packageResource.getEmpty().then(scaffold => {
|
||||
vm.package = scaffold;
|
||||
|
||||
function selectMediaType(mediatype) {
|
||||
loadResources();
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.mediaTypes.indexOf(mediatype.id);
|
||||
vm.loading = false;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.mediaTypes.push(mediatype.id);
|
||||
} else {
|
||||
vm.package.mediaTypes.splice(index, 1);
|
||||
localizationService.localizeMany(["general_create", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
} else {
|
||||
// Load package
|
||||
packageResource.getCreatedById(packageId).then(createdPackage => {
|
||||
vm.package = createdPackage;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
|
||||
// Get render model for content node
|
||||
if (vm.package.contentNodeId) {
|
||||
entityResource.getById(vm.package.contentNodeId, "Document")
|
||||
.then((entity) => {
|
||||
vm.contentNodeDisplayModel = entity;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selectTemplate(template) {
|
||||
vm.mediaPickerModel.value = vm.package.mediaUdis.join(',');
|
||||
});
|
||||
|
||||
// Check if the template is already selected.
|
||||
var index = vm.package.templates.indexOf(template.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.templates.push(template.id);
|
||||
} else {
|
||||
vm.package.templates.splice(index, 1);
|
||||
}
|
||||
}
|
||||
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selectStyleSheet(stylesheet) {
|
||||
function loadResources() {
|
||||
|
||||
// Check if the style sheet is already selected.
|
||||
var index = vm.package.stylesheets.indexOf(stylesheet.name);
|
||||
// Get all document types
|
||||
entityResource.getAll("DocumentType").then(documentTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
documentTypes.forEach(documentType => {
|
||||
documentType.id = documentType.id.toString();
|
||||
documentType.selected = vm.package.documentTypes.indexOf(documentType.id) !== -1;
|
||||
});
|
||||
vm.documentTypes = documentTypes;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.stylesheets.push(stylesheet.name);
|
||||
} else {
|
||||
vm.package.stylesheets.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all media types
|
||||
entityResource.getAll("MediaType").then(mediaTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
mediaTypes.forEach(mediaType => {
|
||||
mediaType.id = mediaType.id.toString();
|
||||
mediaType.selected = vm.package.mediaTypes.indexOf(mediaType.id) !== -1;
|
||||
});
|
||||
vm.mediaTypes = mediaTypes;
|
||||
});
|
||||
|
||||
function selectMacro(macro) {
|
||||
// Get all templates
|
||||
entityResource.getAll("Template").then(templates => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
templates.forEach(template => {
|
||||
template.id = template.id.toString();
|
||||
template.selected = vm.package.templates.indexOf(template.id) >= 0;
|
||||
});
|
||||
vm.templates = templates;
|
||||
});
|
||||
|
||||
// Check if the macro is already selected.
|
||||
var index = vm.package.macros.indexOf(macro.id);
|
||||
// Get all stylesheets
|
||||
entityResource.getAll("Stylesheet").then(stylesheets => {
|
||||
stylesheets.forEach(stylesheet => {
|
||||
stylesheet.selected = vm.package.stylesheets.indexOf(stylesheet.path) >= 0;
|
||||
});
|
||||
vm.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.macros.push(macro.id);
|
||||
} else {
|
||||
vm.package.macros.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all scripts
|
||||
entityResource.getAll("Script").then(scripts => {
|
||||
scripts.forEach(script => {
|
||||
script.selected = vm.package.scripts.indexOf(script.path) >= 0;
|
||||
});
|
||||
vm.scripts = scripts;
|
||||
});
|
||||
|
||||
function selectLanguage(language) {
|
||||
// Get all partial views
|
||||
entityResource.getAll("PartialView").then(partialViews => {
|
||||
partialViews.forEach(view => {
|
||||
view.selected = vm.package.partialViews.indexOf(view.path) >= 0;
|
||||
});
|
||||
vm.partialViews = partialViews;
|
||||
});
|
||||
|
||||
// Check if the language is already selected.
|
||||
var index = vm.package.languages.indexOf(language.id);
|
||||
// Get all macros
|
||||
entityResource.getAll("Macro").then(macros => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
macros.forEach(macro => {
|
||||
macro.id = macro.id.toString();
|
||||
macro.selected = vm.package.macros.indexOf(macro.id) !== -1;
|
||||
});
|
||||
vm.macros = macros;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.languages.push(language.id);
|
||||
} else {
|
||||
vm.package.languages.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all languages
|
||||
entityResource.getAll("Language").then(languages => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
languages.forEach(language => {
|
||||
language.id = language.id.toString();
|
||||
language.selected = vm.package.languages.indexOf(language.id) !== -1;
|
||||
});
|
||||
vm.languages = languages;
|
||||
});
|
||||
|
||||
function selectDictionaryItem(dictionaryItem) {
|
||||
// Get all dictionary items
|
||||
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dictionaryItems.forEach(dictionaryItem => {
|
||||
dictionaryItem.id = dictionaryItem.id.toString();
|
||||
dictionaryItem.selected = vm.package.dictionaryItems.indexOf(dictionaryItem.id) !== -1;
|
||||
});
|
||||
vm.dictionaryItems = dictionaryItems;
|
||||
});
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dictionaryItems.indexOf(dictionaryItem.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dictionaryItems.push(dictionaryItem.id);
|
||||
} else {
|
||||
vm.package.dictionaryItems.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDataType(dataType) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dataTypes.indexOf(dataType.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dataTypes.push(dataType.id);
|
||||
} else {
|
||||
vm.package.dataTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function getVals(array) {
|
||||
var vals = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
vals.push({ value: array[i] });
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
|
||||
onInit();
|
||||
// Get all data types
|
||||
entityResource.getAll("DataType").then(dataTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dataTypes.forEach(dataType => {
|
||||
dataType.id = dataType.id.toString();
|
||||
dataType.selected = vm.package.dataTypes.indexOf(dataType.id) !== -1;
|
||||
});
|
||||
vm.dataTypes = dataTypes;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Packages.EditController", EditController);
|
||||
function downloadFile(id) {
|
||||
var url = umbRequestHelper.getApiUrl(
|
||||
"packageApiBaseUrl",
|
||||
"DownloadCreatedPackage",
|
||||
{ id: id });
|
||||
|
||||
umbRequestHelper.downloadFile(url).then(function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function back() {
|
||||
$location.path("packages/packages/created").search("create", null).search("packageId", null);
|
||||
}
|
||||
|
||||
function createOrUpdatePackage(editPackageForm) {
|
||||
|
||||
// Split by comma and remove empty entries
|
||||
vm.package.mediaUdis = vm.mediaPickerModel.value.split(",").filter(i => i);
|
||||
if (formHelper.submitForm({ formCtrl: editPackageForm, scope: $scope })) {
|
||||
|
||||
vm.buttonState = "busy";
|
||||
|
||||
packageResource.savePackage(vm.package).then((updatedPackage) => {
|
||||
|
||||
vm.package = updatedPackage;
|
||||
vm.buttonState = "success";
|
||||
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm });
|
||||
|
||||
if (create) {
|
||||
//if we are creating, then redirect to the correct url and reload
|
||||
$location.path("packages/packages/edit/" + vm.package.id).search("create", null);
|
||||
//don't add a browser history for this
|
||||
$location.replace();
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm, hasErrors: true });
|
||||
formHelper.handleError(err);
|
||||
vm.buttonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeContentItem() {
|
||||
vm.package.contentNodeId = null;
|
||||
}
|
||||
|
||||
function openContentPicker() {
|
||||
const contentPicker = {
|
||||
submit: function (model) {
|
||||
if (model.selection && model.selection.length > 0) {
|
||||
vm.package.contentNodeId = model.selection[0].id.toString();
|
||||
vm.contentNodeDisplayModel = model.selection[0];
|
||||
}
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.contentPicker(contentPicker);
|
||||
}
|
||||
|
||||
function openViewPicker() {
|
||||
const controlPicker = {
|
||||
title: "Select view",
|
||||
section: "settings",
|
||||
treeAlias: "files",
|
||||
entityType: "file",
|
||||
onlyInitialized: false,
|
||||
filter: function (i) {
|
||||
if (i.name.indexOf(".html") === -1 &&
|
||||
i.name.indexOf(".htm") === -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
filterCssClass: "not-allowed",
|
||||
select: function (node) {
|
||||
const id = decodeURIComponent(node.id.replace(/\+/g, " "));
|
||||
vm.package.packageView = id;
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.treePicker(controlPicker);
|
||||
}
|
||||
|
||||
function removePackageView() {
|
||||
vm.package.packageView = null;
|
||||
}
|
||||
|
||||
function selectDocumentType(doctype) {
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.documentTypes.indexOf(doctype.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.documentTypes.push(doctype.id);
|
||||
} else {
|
||||
vm.package.documentTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectMediaType(mediatype) {
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.mediaTypes.indexOf(mediatype.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.mediaTypes.push(mediatype.id);
|
||||
} else {
|
||||
vm.package.mediaTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectTemplate(template) {
|
||||
|
||||
// Check if the template is already selected.
|
||||
var index = vm.package.templates.indexOf(template.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.templates.push(template.id);
|
||||
} else {
|
||||
vm.package.templates.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectStyleSheet(stylesheet) {
|
||||
|
||||
// Check if the style sheet is already selected.
|
||||
var index = vm.package.stylesheets.indexOf(stylesheet.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.stylesheets.push(stylesheet.path);
|
||||
} else {
|
||||
vm.package.stylesheets.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectScript(script) {
|
||||
|
||||
// Check if the script is already selected.
|
||||
var index = vm.package.scripts.indexOf(script.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.scripts.push(script.path);
|
||||
} else {
|
||||
vm.package.scripts.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectPartialView(view) {
|
||||
|
||||
// Check if the view is already selected.
|
||||
var index = vm.package.partialViews.indexOf(view.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.partialViews.push(view.path);
|
||||
} else {
|
||||
vm.package.partialViews.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectMacro(macro) {
|
||||
|
||||
// Check if the macro is already selected.
|
||||
var index = vm.package.macros.indexOf(macro.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.macros.push(macro.id);
|
||||
} else {
|
||||
vm.package.macros.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectLanguage(language) {
|
||||
|
||||
// Check if the language is already selected.
|
||||
var index = vm.package.languages.indexOf(language.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.languages.push(language.id);
|
||||
} else {
|
||||
vm.package.languages.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDictionaryItem(dictionaryItem) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dictionaryItems.indexOf(dictionaryItem.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dictionaryItems.push(dictionaryItem.id);
|
||||
} else {
|
||||
vm.package.dictionaryItems.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDataType(dataType) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dataTypes.indexOf(dataType.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dataTypes.push(dataType.id);
|
||||
} else {
|
||||
vm.package.dataTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function getVals(array) {
|
||||
var vals = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
vals.push({ value: array[i] });
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Packages.EditController", EditController);
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,177 +1,193 @@
|
||||
<div data-element="editor-packages" ng-controller="Umbraco.Editors.Packages.EditController as vm">
|
||||
|
||||
<form name="editPackageForm" no-validate val-form-manager>
|
||||
<form name="editPackageForm" no-validate val-form-manager>
|
||||
|
||||
<umb-editor-view>
|
||||
<umb-editor-view>
|
||||
|
||||
<umb-editor-header
|
||||
name="vm.package.name"
|
||||
on-back="vm.back()"
|
||||
show-back-button="vm.showBackButton"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
<umb-editor-header name="vm.package.name"
|
||||
on-back="vm.back()"
|
||||
show-back-button="vm.showBackButton"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container class="form-horizontal">
|
||||
<umb-editor-container class="form-horizontal">
|
||||
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
|
||||
<div class="umb-expansion-panel">
|
||||
<div class="umb-expansion-panel">
|
||||
|
||||
<div class="umb-expansion-panel__header">
|
||||
<span><localize key="packager_packageContent">Package Content</localize></span>
|
||||
</div>
|
||||
<div class="umb-expansion-panel__header">
|
||||
<span><localize key="packager_packageContent">Package Content</localize></span>
|
||||
</div>
|
||||
|
||||
<div class="umb-expansion-panel__content">
|
||||
<div class="umb-expansion-panel__content">
|
||||
|
||||
<umb-control-group label="@general_content">
|
||||
<umb-control-group label="@general_content">
|
||||
|
||||
<umb-node-preview
|
||||
ng-if="vm.package.contentNodeId"
|
||||
<umb-node-preview ng-if="vm.package.contentNodeId"
|
||||
icon="vm.contentNodeDisplayModel.icon"
|
||||
name="vm.contentNodeDisplayModel.name"
|
||||
allow-edit="true"
|
||||
allow-remove="true"
|
||||
on-edit="vm.openContentPicker()"
|
||||
on-remove="vm.removeContentItem()">
|
||||
</umb-node-preview>
|
||||
</umb-node-preview>
|
||||
|
||||
<button type="button"
|
||||
ng-if="!vm.package.contentNodeId"
|
||||
style="margin-bottom: 10px;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()">
|
||||
<localize key="general_add">Add</localize>
|
||||
</button>
|
||||
<button type="button"
|
||||
ng-if="!vm.package.contentNodeId"
|
||||
style="margin-bottom: 10px;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()">
|
||||
<localize key="general_add">Add</localize>
|
||||
</button>
|
||||
|
||||
<umb-checkbox model="vm.package.contentLoadChildNodes"
|
||||
disabled="!vm.package.contentNodeId"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
<umb-checkbox model="vm.package.contentLoadChildNodes"
|
||||
disabled="!vm.package.contentNodeId"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
|
||||
</umb-control-group>
|
||||
</umb-control-group>
|
||||
|
||||
|
||||
|
||||
<umb-control-group label="@general_media">
|
||||
<umb-control-group label="@general_media">
|
||||
|
||||
|
||||
|
||||
<umb-property property="vm.mediaPickerModel" ng-if="vm.loading === false">
|
||||
<umb-property-editor model="vm.mediaPickerModel" is-pre-value="true"></umb-property-editor>
|
||||
</umb-property>
|
||||
<umb-property property="vm.mediaPickerModel" ng-if="vm.loading === false">
|
||||
<umb-property-editor model="vm.mediaPickerModel" is-pre-value="true"></umb-property-editor>
|
||||
</umb-property>
|
||||
|
||||
<umb-checkbox model="vm.package.mediaLoadChildNodes"
|
||||
disabled="vm.mediaPickerModel.value.length === 0"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
</umb-control-group>
|
||||
<umb-checkbox model="vm.package.mediaLoadChildNodes"
|
||||
disabled="vm.mediaPickerModel.value.length === 0"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_documentTypes">
|
||||
<div ng-repeat="doctype in ::vm.documentTypes | orderBy:'name'">
|
||||
<umb-checkbox model="doctype.selected"
|
||||
on-change="vm.selectDocumentType(doctype)"
|
||||
text="{{doctype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_documentTypes">
|
||||
<div ng-repeat="doctype in ::vm.documentTypes | orderBy:'name'">
|
||||
<umb-checkbox model="doctype.selected"
|
||||
on-change="vm.selectDocumentType(doctype)"
|
||||
text="{{doctype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_mediaTypes">
|
||||
<div ng-repeat="mediatype in ::vm.mediaTypes | orderBy:'name'">
|
||||
<umb-checkbox model="mediatype.selected"
|
||||
on-change="vm.selectMediaType(mediatype)"
|
||||
text="{{mediatype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_mediaTypes">
|
||||
<div ng-repeat="mediatype in ::vm.mediaTypes | orderBy:'name'">
|
||||
<umb-checkbox model="mediatype.selected"
|
||||
on-change="vm.selectMediaType(mediatype)"
|
||||
text="{{mediatype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_templates">
|
||||
<div ng-repeat="template in ::vm.templates | orderBy:'name'">
|
||||
<umb-checkbox model="template.selected"
|
||||
on-change="vm.selectTemplate(template)"
|
||||
text="{{template.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_macros">
|
||||
<div ng-repeat="macro in ::vm.macros | orderBy:'name'">
|
||||
<umb-checkbox model="macro.selected"
|
||||
on-change="vm.selectMacro(macro)"
|
||||
text="{{macro.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_stylesheets">
|
||||
<div ng-repeat="stylesheet in ::vm.stylesheets | orderBy:'name'">
|
||||
<umb-checkbox model="stylesheet.selected"
|
||||
on-change="vm.selectStyleSheet(stylesheet)"
|
||||
text="{{stylesheet.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_languages">
|
||||
<div ng-repeat="language in ::vm.languages | orderBy:'name'">
|
||||
<umb-checkbox model="language.selected"
|
||||
on-change="vm.selectLanguage(language)"
|
||||
text="{{language.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_macros">
|
||||
<div ng-repeat="macro in ::vm.macros | orderBy:'name'">
|
||||
<umb-checkbox model="macro.selected"
|
||||
on-change="vm.selectMacro(macro)"
|
||||
text="{{macro.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_dictionary">
|
||||
<div ng-repeat="dictionaryItem in ::vm.dictionaryItems | orderBy:'name'">
|
||||
<umb-checkbox model="dictionaryItem.selected"
|
||||
on-change="vm.selectDictionaryItem(dictionaryItem)"
|
||||
text="{{dictionaryItem.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_languages">
|
||||
<div ng-repeat="language in ::vm.languages | orderBy:'name'">
|
||||
<umb-checkbox model="language.selected"
|
||||
on-change="vm.selectLanguage(language)"
|
||||
text="{{language.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_dataTypes">
|
||||
<div ng-repeat="dataType in ::vm.dataTypes | orderBy:'name'">
|
||||
<umb-checkbox model="dataType.selected"
|
||||
on-change="vm.selectDataType(dataType)"
|
||||
text="{{dataType.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_dictionary">
|
||||
<div ng-repeat="dictionaryItem in ::vm.dictionaryItems | orderBy:'name'">
|
||||
<umb-checkbox model="dictionaryItem.selected"
|
||||
on-change="vm.selectDictionaryItem(dictionaryItem)"
|
||||
text="{{dictionaryItem.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_templates">
|
||||
<div ng-repeat="template in ::vm.templates | orderBy:'name'">
|
||||
<umb-checkbox model="template.selected"
|
||||
on-change="vm.selectTemplate(template)"
|
||||
text="{{template.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_dataTypes">
|
||||
<div ng-repeat="dataType in ::vm.dataTypes | orderBy:'name'">
|
||||
<umb-checkbox model="dataType.selected"
|
||||
on-change="vm.selectDataType(dataType)"
|
||||
text="{{dataType.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_stylesheets">
|
||||
<div ng-repeat="stylesheet in ::vm.stylesheets | orderBy:'path'">
|
||||
<umb-checkbox model="stylesheet.selected"
|
||||
on-change="vm.selectStyleSheet(stylesheet)"
|
||||
text="{{stylesheet.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</div>
|
||||
<umb-control-group label="@treeHeaders_scripts">
|
||||
<div ng-repeat="script in ::vm.scripts | orderBy:'path'">
|
||||
<umb-checkbox model="script.selected"
|
||||
on-change="vm.selectScript(script)"
|
||||
text="{{script.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</div>
|
||||
<umb-control-group label="@treeHeaders_partialViews">
|
||||
<div ng-repeat="partialView in ::vm.partialViews | orderBy:'path'">
|
||||
<umb-checkbox model="partialView.selected"
|
||||
on-change="vm.selectPartialView(partialView)"
|
||||
text="{{partialView.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</umb-editor-container>
|
||||
</div>
|
||||
|
||||
<umb-editor-footer>
|
||||
</div>
|
||||
|
||||
<umb-editor-footer-content-right>
|
||||
</umb-editor-container>
|
||||
|
||||
<umb-button ng-if="vm.package.packagePath"
|
||||
type="button"
|
||||
action="vm.downloadFile(vm.package.id)"
|
||||
disabled="vm.loading || vm.buttonState=='busy'"
|
||||
button-style="info"
|
||||
label-key="general_download">
|
||||
</umb-button>
|
||||
<umb-editor-footer>
|
||||
|
||||
<umb-button type="button"
|
||||
action="vm.createOrUpdatePackage(editPackageForm)"
|
||||
state="vm.buttonState"
|
||||
button-style="success"
|
||||
label="{{vm.labels.button}}"
|
||||
disabled="vm.loading">
|
||||
</umb-button>
|
||||
<umb-editor-footer-content-right>
|
||||
|
||||
</umb-editor-footer-content-right>
|
||||
<umb-button ng-if="vm.package.packagePath"
|
||||
type="button"
|
||||
action="vm.downloadFile(vm.package.id)"
|
||||
disabled="vm.loading || vm.buttonState=='busy'"
|
||||
button-style="info"
|
||||
label-key="general_download">
|
||||
</umb-button>
|
||||
|
||||
</umb-editor-footer>
|
||||
<umb-button type="button"
|
||||
action="vm.createOrUpdatePackage(editPackageForm)"
|
||||
state="vm.buttonState"
|
||||
button-style="success"
|
||||
label="{{vm.labels.button}}"
|
||||
disabled="vm.loading">
|
||||
</umb-button>
|
||||
|
||||
</umb-editor-view>
|
||||
</umb-editor-footer-content-right>
|
||||
|
||||
</form>
|
||||
</umb-editor-footer>
|
||||
|
||||
</umb-editor-view>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user