diff --git a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/orderedMapEnhancer.coffee b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/orderedMapEnhancer.coffee index 87f957867e..b19db7eb38 100644 --- a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/orderedMapEnhancer.coffee +++ b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/orderedMapEnhancer.coffee @@ -2,11 +2,15 @@ angular.module('mc.core.orderedMapEnhancer', ['mc.util.enhance']).config ['enhan condition = (orderedMap) -> orderedMap.hasOwnProperty('type') and orderedMap.type == 'orderedMap' factory = [ 'enhance', (enhance)-> orderedMapEnhancer = (orderedMap) -> + ensureValuesAreArray = (map) -> + return if map.values and angular.isArray(map.values) + map.values = [] orderedMap.get = (key) -> @access(key).get() orderedMap.access = (key) -> self = @ set = (newValue) -> + ensureValuesAreArray(self) for value in self.values if value.key == key value.value = newValue @@ -15,6 +19,7 @@ angular.module('mc.core.orderedMapEnhancer', ['mc.util.enhance']).config ['enhan self.values.push(key: key, value: newValue) if newValue or not key return newValue get = -> + ensureValuesAreArray(self) for value in self.values if value.key == key return value.value @@ -29,6 +34,7 @@ angular.module('mc.core.orderedMapEnhancer', ['mc.util.enhance']).config ['enhan getterSetter.get = -> get() getterSetter.set = (newValue) -> set(newValue) getterSetter.remove = -> + ensureValuesAreArray(self) result = undefined for value, i in self.values[..].reverse() if value.key == key @@ -46,10 +52,12 @@ angular.module('mc.core.orderedMapEnhancer', ['mc.util.enhance']).config ['enhan orderedMap.clearIfOnlyContainsPlaceholder = -> + ensureValuesAreArray(@) if @values.length == 1 and not @values[0].value @values = [] orderedMap.addPlaceholderIfEmpty = -> + ensureValuesAreArray(@) if @values.length == 0 @values = [{key: ''}] orderedMap diff --git a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementProperties.coffee b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementProperties.coffee index 7cb6cbae4d..ac465e39bc 100644 --- a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementProperties.coffee +++ b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementProperties.coffee @@ -238,7 +238,7 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu isDirty: -> if @value and enhance.isEnhancedBy(@value, 'orderedMap') and @original and enhance.isEnhancedBy(@original, 'orderedMap') return false if angular.equals(@value.values, @original.values) - return false if @original.values.length == 0 and @value.values.length == 1 and not @value.values[0].value and not @value.values[0].key + return false if (@original.values ? []).length == 0 and @value.values.length == 1 and not @value.values[0].value and not @value.values[0].key !angular.equals(@original, @value) reset: -> @value = angular.copy @original update: -> @@ -267,7 +267,7 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu if $value?.type == 'orderedMap' - for value in $value.values when not angular.isObject(value.value) + for value in ($value.values ? []) when not angular.isObject(value.value) tabDefinition.properties.push { label: value.key value: getSortedMapPropertyVal(value.key) diff --git a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementTreeviewItem.coffee b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementTreeviewItem.coffee index 24ad745a0f..b9f76f459e 100644 --- a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementTreeviewItem.coffee +++ b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/bs/catalogueElementTreeviewItem.coffee @@ -18,7 +18,7 @@ cetiModule.run [ '$templateCache', ($templateCache) -> - {{element.$$localName || element.name}} {{element.name}} {{element.latestVersionId}}.{{element.versionNumber}} + {{element.$$localName || element.name}} {{element.name}} {{element.latestVersionId}}.{{element.versionNumber}} diff --git a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/catalogueElementTreeview.coffee b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/catalogueElementTreeview.coffee index cb174e2ec8..3990ba3e58 100644 --- a/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/catalogueElementTreeview.coffee +++ b/ModelCatalogueCorePlugin/grails-app/assets/javascripts/modelcatalogue/core/ui/catalogueElementTreeview.coffee @@ -37,6 +37,7 @@ angular.module('mc.core.ui.catalogueElementTreeview', ['mc.core.ui.catalogueElem addItemsFromList = (list) -> return if list.$$children + return if not list.list list.$$children = [] for item in list.list cachedChild = if list.$$cachedChildren then list.$$cachedChildren[item.link] @@ -76,6 +77,7 @@ angular.module('mc.core.ui.catalogueElementTreeview', ['mc.core.ui.catalogueElem $scope.showMore = () -> return if $scope.$$showingMore + return if not nextFun $scope.$$showingMore = true return unless $scope.list.total > $scope.list.$$children.length params = {}