Skip to content

Commit

Permalink
Highlight the latest version in component cards. Resolve Wirecloud#190
Browse files Browse the repository at this point in the history
  • Loading branch information
jpajuelo committed Oct 26, 2016
1 parent de8edbc commit e0b4df8
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
this.imageElement = document.createElement('img');
this.imageElement.onerror = image_onerror.bind(this);

var version = new se.Select();
var version = new se.Select({
initialValue: resource.version,
initialEntries: orderVersions([resource.version].concat(resource.others))
});
version.addEventListener('change', version_onchange.bind(this));
version.addEntries([resource.version].concat(resource.others));

var button = new se.Button({
class: 'btn-create wc-create-resource-component',
Expand Down Expand Up @@ -129,4 +131,23 @@
this.imageElement.parentElement.appendChild(document.createTextNode(utils.gettext("No image available")));
};

var orderVersions = function orderVersions(versions) {
versions = versions.map(function (value) {
return new Wirecloud.Version(value);
}).sort(function (version1, version2) {
return -version1.compareTo(version2);
}).map(function (version, i) {
return {
label: "v" + version,
value: version.text
};
});

versions[0].label = utils.interpolate(utils.gettext("%(version)s (latest)"), {
version: versions[0].label
});

return versions;
};

})(Wirecloud.ui.WiringEditor, StyledElements, StyledElements.Utils);

0 comments on commit e0b4df8

Please sign in to comment.