on xenial help sign in
Add max-count for attributes
fefea98Ying-Chun Liu
qml/Dash/CardTool.qml+4−2
@@ -171,10 +171,12 @@ Item {
171 property var model: []
171 property var model: []
172 property bool hasAttributes: {
172 property bool hasAttributes: {
173 var attributes = components["attributes"];
173 var attributes = components["attributes"];
174− var hasAttributesFlag = attributes != undefined;
174+ var hasAttributesFlag = (attributes != undefined) && attributes["field"];
175 // TODO: we should get num of attributes from components
175 // TODO: we should get num of attributes from components
176 if (hasAttributesFlag) {
176 if (hasAttributesFlag) {
177+ if (attributes["max-count"]) {
177− numOfAttributes = 3;
178+ numOfAttributes = attributes["max-count"];
179+ }
178 }
180 }
179 return hasAttributesFlag
181 return hasAttributesFlag
180 }
182 }
tests/plugins/Dash/cardcreator/7.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
1template: {"card-background":{"elements":["#E9E9E9"],"type":"color"},"card-layout":"vertical","card-size":"medium","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{"field":"attributes"}}
2+components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{"field":"attributes","max-count":2}}
3result: 7.res
3result: 7.res
tests/qmltests/Dash/CardHelpers.js+1−1
@@ -49,7 +49,7 @@ var defaultLayout = ' \
49 }, \
49 }, \
50 "alt-rating": null, \
50 "alt-rating": null, \
51 "summary": null, \
51 "summary": null, \
52− "attributes": null \
52+ "attributes": { "max-count": 2 } \
53 }, \
53 }, \
54 "resources": {} \
54 "resources": {} \
55}'
55}'