add vm.model.onValueChanged callback
(cherry picked from commit 8ebb37a596)
# Conflicts:
# src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker3/umbMediaPicker3PropertyEditor.component.js
This commit is contained in:
committed by
Sebastiaan Janssen
parent
f04e27ca19
commit
3def2ee2ad
@@ -93,6 +93,10 @@
|
|||||||
|
|
||||||
vm.model.value.forEach(mediaEntry => updateMediaEntryData(mediaEntry));
|
vm.model.value.forEach(mediaEntry => updateMediaEntryData(mediaEntry));
|
||||||
|
|
||||||
|
// set the onValueChanged callback, this will tell us if the media picker model changed on the server
|
||||||
|
// once the data is submitted. If so we need to re-initialize
|
||||||
|
vm.model.onValueChanged = onServerValueChanged;
|
||||||
|
|
||||||
userService.getCurrentUser().then(function (userData) {
|
userService.getCurrentUser().then(function (userData) {
|
||||||
|
|
||||||
if (!vm.model.config.startNodeId) {
|
if (!vm.model.config.startNodeId) {
|
||||||
@@ -115,6 +119,15 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onServerValueChanged(newVal, oldVal) {
|
||||||
|
if(newVal === null || !Array.isArray(newVal)) {
|
||||||
|
newVal = [];
|
||||||
|
vm.model.value = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.model.value.forEach(mediaEntry => updateMediaEntryData(mediaEntry));
|
||||||
|
}
|
||||||
|
|
||||||
function setDirty() {
|
function setDirty() {
|
||||||
if (vm.propertyForm) {
|
if (vm.propertyForm) {
|
||||||
vm.propertyForm.$setDirty();
|
vm.propertyForm.$setDirty();
|
||||||
|
|||||||
Reference in New Issue
Block a user