on xenial help sign in
More fixes
5f9d05aAndrea Cimitan
plugins/Dash/CardCreator.js+16−12
@@ -332,7 +332,7 @@ function cardString(template, components) {
332 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
332 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
333 var hasSubtitle = hasTitle && components["subtitle"] || false;
333 var hasSubtitle = hasTitle && components["subtitle"] || false;
334 var hasHeaderRow = hasMascot && hasTitle;
334 var hasHeaderRow = hasMascot && hasTitle;
335− var hasAttributes = hasTitle && components["attributes"] || false;
335+ var hasAttributes = hasTitle && components["attributes"]["field"] || false;
336
336
337 if (hasBackground) {
337 if (hasBackground) {
338 code += kBackgroundLoaderCode;
338 code += kBackgroundLoaderCode;
@@ -443,6 +443,7 @@ function cardString(template, components) {
443
443
444 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey")';
444 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : (root.scopeStyle ? root.scopeStyle.foreground : "grey")';
445
445
446+ var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
446 var titleSubtitleCode = '';
447 var titleSubtitleCode = '';
447 if (hasTitle) {
448 if (hasTitle) {
448 var titleColor;
449 var titleColor;
@@ -480,7 +481,7 @@ function cardString(template, components) {
480 rightMargin: units.gu(1); \n';
481 rightMargin: units.gu(1); \n';
481 }
482 }
482
483
483− if (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes))) {
484+ if (hasTitleContainer) {
484 // Using headerTitleContainer
485 // Using headerTitleContainer
485 titleAnchors = titleRightAnchor;
486 titleAnchors = titleRightAnchor;
486 titleAnchors += 'left: parent.left; \n\
487 titleAnchors += 'left: parent.left; \n\
@@ -557,7 +558,7 @@ function cardString(template, components) {
557 containerHeight += ' + attributesRow.height';
558 containerHeight += ' + attributesRow.height';
558 }
559 }
559
560
560− if (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes))) {
561+ if (hasTitleContainer) {
561 // use container
562 // use container
562 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
563 titleSubtitleCode = kHeaderContainerCodeGenerator(titleContainerAnchors, containerHeight, containerCode);
563 } else {
564 } else {
@@ -587,7 +588,7 @@ function cardString(template, components) {
587 if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
588 if (isHorizontal && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
588 else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
589 else if (headerAsOverlay && hasArt) summaryTopAnchor = 'artShapeHolder.bottom';
589 else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
590 else if (hasHeaderRow) summaryTopAnchor = 'row.bottom';
590− else if (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes))) summaryTopAnchor = 'headerTitleContainer.bottom';
591+ else if (hasTitleContainer) summaryTopAnchor = 'headerTitleContainer.bottom';
591 else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
592 else if (hasMascot) summaryTopAnchor = 'mascotImage.bottom';
592 else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
593 else if (hasAttributes) summaryTopAnchor = 'attributesRow.bottom';
593 else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
594 else if (hasSubtitle) summaryTopAnchor = 'subtitleLabel.bottom';
@@ -617,23 +618,26 @@ function cardString(template, components) {
617 }
618 }
618 code += kTouchdownCode.arg(touchdownAnchors);
619 code += kTouchdownCode.arg(touchdownAnchors);
619
620
621+ var implicitHeight = 'implicitHeight: ';
620 if (hasSummary) {
622 if (hasSummary) {
621− code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
623+ implicitHeight += 'summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
622 } else if (hasHeaderRow) {
624 } else if (hasHeaderRow) {
623− code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
625+ implicitHeight += 'row.y + row.height + units.gu(1);\n';
624 } else if (hasMascot) {
626 } else if (hasMascot) {
625− code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
627+ implicitHeight += 'mascotImage.y + mascotImage.height;\n';
628+ } else if (hasTitleContainer) {
629+ implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
626 } else if (hasAttributes) {
630 } else if (hasAttributes) {
627− code += 'implicitHeight: attributesRow.y + attributesRow.height + units.gu(1);\n';
631+ implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
628 } else if (hasSubtitle) {
632 } else if (hasSubtitle) {
629− code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
633+ implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
630 } else if (hasTitle) {
634 } else if (hasTitle) {
631− code += 'implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);\n';
635+ implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
632 } else if (hasArt) {
636 } else if (hasArt) {
633− code += 'implicitHeight: artShapeHolder.height;\n';
637+ implicitHeight += 'artShapeHolder.height;\n';
634 }
638 }
635 // Close the AbstractButton
639 // Close the AbstractButton
636− code += '}\n';
640+ code += implicitHeight + '}\n';
637
641
638 return code;
642 return code;
639}
643}
tests/plugins/Dash/cardcreator/1.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1.6,"field":"art","fill-mode":"fit"},"title":{"field":"title"}}
2+components: {"art":{"aspect-ratio":1.6,"field":"art","fill-mode":"fit"},"title":{"field":"title"},"attributes":{}}
3result: 1.res
3result: 1.res
tests/plugins/Dash/cardcreator/2.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"}}
2+components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"background":{"field":"background"},"mascot":{"field":"icon"},"subtitle":{"field":"author"},"title":{"field":"title"},"attributes":{}}
3result: 2.res
3result: 2.res
tests/plugins/Dash/cardcreator/3.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":0.75,"field":"art","fill-mode":"crop"},"subtitle":{"field":"price"},"title":{"field":"title"}}
2+components: {"art":{"aspect-ratio":0.75,"field":"art","fill-mode":"crop"},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{}}
3result: 3.res
3result: 3.res
tests/plugins/Dash/cardcreator/4.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-layout":"horizontal","card-size":"large","category-layout":"grid","collapsed-rows":2}
1template: {"card-layout":"horizontal","card-size":"large","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"mascot":{"field":"mascot"},"subtitle":{"field":"domain"},"title":{"field":"title"}}
2+components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"mascot":{"field":"mascot"},"subtitle":{"field":"domain"},"title":{"field":"title"},"attributes":{}}
3result: 4.res
3result: 4.res
tests/plugins/Dash/cardcreator/5.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
1template: {"card-layout":"vertical","card-size":"medium","category-layout":"carousel","collapsed-rows":2,"overlay":true}
2−components: {"art":{"aspect-ratio":1,"field":"art","fill-mode":"crop"},"subtitle":{"field":"artist"},"title":{"field":"title"}}
2+components: {"art":{"aspect-ratio":1,"field":"art","fill-mode":"crop"},"subtitle":{"field":"artist"},"title":{"field":"title"},"attributes":{}}
3result: 5.res
3result: 5.res
tests/plugins/Dash/cardcreator/6.res+1−1
@@ -118,5 +118,5 @@ UbuntuShape {
118 radius: "medium";
118 radius: "medium";
119 borderSource: "radius_pressed.sci"
119 borderSource: "radius_pressed.sci"
120}
120}
121−implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
121+implicitHeight: headerTitleContainer.y + headerTitleContainer.height + units.gu(1);
122}
122}
tests/plugins/Dash/cardcreator/6.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"},"subtitle":{"field":"author"},"title":{"field":"title"},"emblem":{"field":"source"}}
2+components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"background":{"field":"background"},"subtitle":{"field":"author"},"title":{"field":"title"},"emblem":{"field":"source"},"attributes":{}}
3result: 6.res
3result: 6.res