~dandrader/unity8/pixelAlignedWindow

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/CardHelpers.js

  • Committer: CI Train Bot
  • Author(s): Andrea Cimitan
  • Date: 2016-05-04 18:08:28 UTC
  • mfrom: (2103.6.33 card-social)
  • Revision ID: ci-train-bot@canonical.com-20160504180828-aetx14xx5yy600eg
Add social actions to cards
Approved by: Josh Arenson

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
.pragma library
18
18
 
19
 
var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "overlayColor", "quickPreviewData"]
 
19
var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "social-actions", "overlayColor", "quickPreviewData"]
 
20
var dataKeys = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "socialActions", "overlayColor", "quickPreviewData"]
20
21
 
21
22
var defaultLayout = ' \
22
23
{ \
38
39
    "mascot": null, \
39
40
    "emblem": null, \
40
41
    "summary": null, \
41
 
    "attributes": { "max-count": 2 } \
 
42
    "attributes": { "max-count": 2 }, \
 
43
    "social-actions": null \
42
44
  }, \
43
45
  "resources": {} \
44
46
}'
52
54
  "emblem": "emblem", \
53
55
  "overlayColor": "overlayColor", \
54
56
  "summary": "summary", \
55
 
  "attributes": "attributes" \
 
57
  "attributes": "attributes", \
 
58
  "social-actions": "socialActions" \
56
59
}'
57
60
 
58
 
 
59
61
function tryParse(json, errorLabel) {
60
62
    var o = undefined;
61
63
    if (errorLabel !== undefined) {
82
84
        for (var k in components) {
83
85
            try {
84
86
                if (typeof layout[components[k]] == "object") {
85
 
                    d[components[k]] = o[layout[components[k]]['field']];
 
87
                    d[dataKeys[k]] = o[layout[components[k]]['field']];
86
88
                } else {
87
 
                    d[components[k]] = o[layout[components[k]]];
 
89
                    d[dataKeys[k]] = o[layout[components[k]]];
88
90
                }
89
91
            } catch(err) {
90
 
                d[components[k]] = undefined;
 
92
                d[dataKeys[k]] = undefined;
91
93
            }
92
94
        }
93
95
    }