Netcore: Package support for media + media types (#9547)

* Add support for media when installing a package

* clean up

* Fix tests

* Add support for media when installing a package

* clean up

* Fix tests

* moved tests + test data

* Migrated package tests + resources

* Fix issue with media picker on package page, was empty after save.

* Added missing files

* Fix casing issue of resources

* Added test for media

* Fix tests for linux

* Fix test

* Fix issue with move media..

* Fix issue with adding files to packages

* Add MediaType permissions.

* Fix test

* Fix test

* Retry flaky tests, and added TODOs to fix those

* new attempt to fix test

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
This commit is contained in:
Bjarke Berg
2020-12-16 22:26:47 +01:00
committed by GitHub
parent 5119e8da9c
commit 0151c435f1
55 changed files with 1130 additions and 953 deletions

View File

@@ -16,6 +16,7 @@
vm.filesOpen = true;
vm.actionsOpen = true;
vm.loading = true;
vm.mediaNodeDisplayModels = [];
vm.back = back;
vm.createOrUpdatePackage = createOrUpdatePackage;
vm.removeContentItem = removeContentItem;
@@ -28,6 +29,7 @@
vm.contributorsEditor = null;
vm.selectDocumentType = selectDocumentType;
vm.selectMediaType = selectMediaType;
vm.selectTemplate = selectTemplate;
vm.selectStyleSheet = selectStyleSheet;
vm.selectMacro = selectMacro;
@@ -35,6 +37,15 @@
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+)$/;
@@ -76,6 +87,7 @@
});
}
vm.mediaPickerModel.value = vm.package.mediaUdis.join(',');
});
@@ -88,20 +100,31 @@
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 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
// 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();
@@ -120,7 +143,7 @@
// Get all macros
entityResource.getAll("Macro").then(macros => {
// a package stores the id as a string so we
// 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();
@@ -131,7 +154,7 @@
// Get all languages
entityResource.getAll("Language").then(languages => {
// a package stores the id as a string so we
// 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();
@@ -142,7 +165,7 @@
// Get all dictionary items
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
// a package stores the id as a string so we
// 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();
@@ -153,7 +176,7 @@
// Get all data types
entityResource.getAll("DataType").then(dataTypes => {
// a package stores the id as a string so we
// 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();
@@ -181,10 +204,12 @@
function createOrUpdatePackage(editPackageForm) {
let contributors = vm.contributorsEditor.value.map(o => o.value);
let contributors = vm.contributorsEditor.value.map(o => o.value)
vm.package.contributors = contributors;
// 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";
@@ -215,23 +240,23 @@
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 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 openFilePicker() {
function openFilePicker() {
let selection = Utilities.copy(vm.package.files);
@@ -313,6 +338,18 @@
}
}
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.

View File

@@ -137,6 +137,22 @@
</umb-control-group>
<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-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"
@@ -146,11 +162,20 @@
</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}}">
text="{{template.name}}">umb-expansion-panel__content
</umb-checkbox>
</div>
</umb-control-group>