Skip to content

Commit

Permalink
Merge branch 'master' into feature/cognito
Browse files Browse the repository at this point in the history
  • Loading branch information
temi committed May 10, 2024
2 parents e5a6433 + 4d39719 commit 3abb1c3
Show file tree
Hide file tree
Showing 7 changed files with 859 additions and 45 deletions.
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 @@ -1259,9 +1259,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 @@ -1274,6 +1272,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 @@ -1324,8 +1324,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

0 comments on commit 3abb1c3

Please sign in to comment.