Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v6.3 #246

Merged
merged 14 commits into from
Apr 24, 2024
Merged

v6.3 #246

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}


version "6.2"
version "6.3-SNAPSHOT"
group "org.grails.plugins"

apply plugin:"eclipse"
Expand Down
9 changes: 4 additions & 5 deletions grails-app/assets/javascripts/forms-knockout-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,7 @@
'init': function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var dataModelItem = valueAccessor();
var behaviours = dataModelItem.get('behaviour');
for (var i = 0; i < behaviours.length; i++) {
var behaviour = behaviours[i];

behaviours && behaviours.forEach(function(behaviour) {
if (behaviour.type == 'pre_populate') {
var config = behaviour.config;
var dataLoaderContext = dataModelItem.context;
Expand All @@ -1245,6 +1243,8 @@
propTarget.loadData(value);
} else if (_.isFunction(propTarget.load)) {
propTarget.load(value);
} else if (propTarget && propTarget.listParent && _.isFunction(propTarget.listParent["load" + propTarget.listName])) {
propTarget.listParent["load" + propTarget.listName](value);
} else if (ko.isObservable(propTarget)) {
propTarget(value);
} else {
Expand Down Expand Up @@ -1295,8 +1295,7 @@
}); // This is a computed rather than a pureComputed as it has a side effect.
});
}
}

});
}
};

Expand Down
23 changes: 22 additions & 1 deletion grails-app/assets/javascripts/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,27 @@ function orEmptyArray(v) {
return _.findWhere(list, obj);
};

parser.functions.deepEquals = function(value1, value2) {
parser.functions.deepEquals = function(value1, value2, isSortArray) {
// set isSortArray to true if content of array is important and not the order i.e. [1,2,3] == [3,2,1]
isSortArray = isSortArray || false;
// Sort arrays in nested objects to ensure that lodash compares arrays correctly
function sortArraysInObject(obj) {
if (_.isArray(obj)) {
obj.sort();
} else if (typeof obj === 'object' && obj !== null) {
for (var key in obj) {
sortArraysInObject(obj[key]); // Recursively call to sort arrays in nested objects
}
}

return obj;
}

if (isSortArray) {
sortArraysInObject(value1);
sortArraysInObject(value2);
}

return _.isEqual(value1, value2);
};

Expand Down Expand Up @@ -1084,6 +1104,7 @@ function orEmptyArray(v) {
var listName = context.listName;
var modelName = context.outputModel.name;

self.listParent = context.parent;
self.listName = listName;
self.addRow = function (data) {
var newItem = self.newItem(data, self.rowCount());
Expand Down
10 changes: 7 additions & 3 deletions grails-app/taglib/au/org/ala/ecodata/forms/ModelTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,12 @@ class ModelTagLib {
}

static boolean getAllowRowDelete(attrs, name, context) {
def ard = getAttribute(attrs, name, context, 'allowRowDelete') ?: 'true'
return ard.toBoolean()
Map dataModel = getAttribute(attrs.model.dataModel, name)
def allowRowDelete = true
if (dataModel?.allowRowDelete != null) {
allowRowDelete = Boolean.valueOf(dataModel.allowRowDelete)
}
allowRowDelete
}


Expand All @@ -1031,7 +1035,7 @@ class ModelTagLib {
return target ? target[attribute] : null
}

def getAttribute(model, name) {
static def getAttribute(Collection model, String name) {
return model.findResult( {

if (it.name == name) {
Expand Down
Loading
Loading