Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Tweak how hide/highlight is rendered in MV.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Adams committed Oct 23, 2014
1 parent c69d880 commit 73010e0
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 12 deletions.
25 changes: 25 additions & 0 deletions app/models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,31 @@ YUI.add('juju-models', function(Y) {
});
},

/**
Returns a list of the deployed (both uncommitted and committed) services
that are not related to this service.
@method findUnrelatedServices
@param {Object} db A reference to the database Model.
@return {Array} A list of the service names of unrelated services.
*/
findUnrelatedServices: function(db) {
var relationData = utils.getRelationDataForService(db, this);
var related = [this.get('name')], // Add own name to related list.
unrelated = [],
serviceName;
// Compile the list of related services.
relationData.forEach(function(relation) {
related.push(relation.far.service);
});
// Find the unrelated by filtering out the related.
unrelated = db.services.filter(function(service) {
serviceName = service.get('name');
return related.indexOf(serviceName) === -1;
});
return unrelated;
},

/**
Detaches all of the events in the models _event property
Expand Down
2 changes: 1 addition & 1 deletion app/templates/container-token-units.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<li class="unit {{#unless agent_state }}uncommitted{{/unless}} {{#if deleted }}deleted{{/if}} {{#if fade}}fade{{/if}} {{#if hide}}hide{{/if}}"
data-id="{{id}}">
{{>more-menu}}
<img src="{{icon}}" alt="{{service}}"/>
<img src="{{icon}}" alt="{{service}}" title="{{displayName}}"/>
<span class="name">
{{displayName}}
<span class="removed">
Expand Down
1 change: 1 addition & 0 deletions app/templates/container-token.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<span class="token-uncommitted">&deg;</span>
</span>
<ul class="service-icons"></ul>
<ul class="service-icons-faded"></ul>
<div class="drop">
<span>Add to container {{ displayName }}</span>
</div>
Expand Down
19 changes: 14 additions & 5 deletions app/widgets/container-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ YUI.add('container-token', function(Y) {
*/
renderUnits: function() {
var machine = this.get('machine');
var units = machine.units;
// Display shown units and faded units in two different lists.
var shownUnits = machine.units.filter(function(u) {
return !(u.fade || u.hide);
});
this.get('container').one('.service-icons').setHTML(
this.unitsTemplate(machine));
this.unitsTemplate({units: shownUnits}));
// Create the more menus for the units.
if (units.length > 0) {
Object.keys(units).forEach(function(index) {
var id = units[index].id;
if (shownUnits.length > 0) {
Object.keys(shownUnits).forEach(function(index) {
var id = shownUnits[index].id;
if (!this._unitMoreMenus) {
this._unitMoreMenus = [];
}
Expand All @@ -184,6 +187,12 @@ YUI.add('container-token', function(Y) {
}
}, this);
}
// Add faded units to the second list.
var fadedUnits = machine.units.filter(function(u) {
return u.fade;
});
this.get('container').one('.service-icons-faded').setHTML(
this.unitsTemplate({units: fadedUnits}));
},

/**
Expand Down
7 changes: 6 additions & 1 deletion app/widgets/machine-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ YUI.add('machine-token', function(Y) {
@method renderUnits
*/
renderUnits: function() {
// Only display shown units.
// TODO refactor filter method to be reused
var shownUnits = this.get('machine').units.filter(function(u) {
return !(u.fade || u.hide);
});
this.get('container').one('.service-icons').setHTML(
this.unitsTemplate(this.get('machine')));
this.unitsTemplate({units: shownUnits}));
},

/**
Expand Down
22 changes: 18 additions & 4 deletions lib/views/machine-view/container-token.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.title {
margin-right: 10px;
}
.service-icons {
.service-icons, .service-icons-faded {
margin-top: 2px;
list-style: none;

Expand All @@ -27,9 +27,6 @@
&.deleted .removed {
display: inline;
}
&.fade {
opacity: 0.2;
}
&.hide {
display: none;
}
Expand Down Expand Up @@ -64,5 +61,22 @@
}
}
}

.service-icons-faded {
.unit {
display: inline-block;
padding: 0;
margin: 0;
.more-menu {
display: none;
}
img {
margin: 0;
}
.name {
display: none;
}
}
}
}
}
2 changes: 1 addition & 1 deletion lib/views/machine-view/machine-view-token-base.less
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
.token-uncommitted {
display: none;
}
.service-icons {
.service-icons, .service-icons-faded {
img {
width: 20px;
height: 20px;
Expand Down

0 comments on commit 73010e0

Please sign in to comment.