Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(337)

Unified Diff: app/models/models.js

Issue 10763045: Add units, unit controls to inspector
Patch Set: Add units, unit controls to inspector Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | app/templates/service-footer-common-controls.partial » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/models/models.js
=== modified file 'app/models/models.js'
--- app/models/models.js 2013-06-27 15:26:46 +0000
+++ app/models/models.js 2013-07-05 16:23:50 +0000
@@ -300,11 +300,26 @@
process_delta: function(action, data, db) {
var instance = _process_delta(this, action, data, {relation_errors: {}});
- if (!instance || !db) {return;}
+ if (!db) {
+ return;
+ }
// Apply this action for this instance to all service models as well.
// In the future we can transition from using db.units to always
- // looking at db.services[serviceId].units
- var service = db.services.getById(instance.service);
+ // looking at db.services[serviceId].units. Note that, in the case of
+ // `action === 'remove'`, instance will be null, so we retrieve the
+ // service name from `data`, which is the removed unit's name.
+ var service;
+ if (!instance) {
+ if (typeof data === 'string') {
+ service = db.services.getById(data.split('/')[0]);
+ } else if (data.service) {
+ service = db.services.getById(data.service);
+ } else {
+ return;
+ }
+ } else {
+ service = db.services.getById(instance.service);
+ }
if (!service) { return; }
// Get the unit list for this service. (lazy)
var unitList = service.get('units');
« no previous file with comments | « [revision details] ('k') | app/templates/service-footer-common-controls.partial » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b