git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
07c55a6
)
replace the onclick itemview handler with a naviation/template based one
author
Scott Baker
<smbaker@gmail.com>
Tue, 2 Dec 2014 18:49:04 +0000
(10:49 -0800)
committer
Scott Baker
<smbaker@gmail.com>
Tue, 2 Dec 2014 18:49:04 +0000
(10:49 -0800)
planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
patch
|
blob
|
history
planetstack/core/xoslib/static/js/xoslib/xosHelper.js
patch
|
blob
|
history
planetstack/core/xoslib/templates/xosAdmin.html
patch
|
blob
|
history
diff --git
a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
index
918e4a2
..
e5ca413
100644
(file)
--- a/
planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/
planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
@@
-70,6
+70,14
@@
if (! window.XOSLIB_LOADED ) {
return res;
\r
},
return res;
\r
},
+ /* If a 'validate' method is supplied, then it will be called
+ automatically on save. Unfortunately, save calls neither the
+ 'error' nor the 'success' callback if the validator fails.
+
+ For now, we're calling our validator 'xosValidate' so this
+ autoamtic validation doesn't occur.
+ */
+
xosValidate: function(attrs, options) {
errors = {};
foundErrors = false;
xosValidate: function(attrs, options) {
errors = {};
foundErrors = false;
@@
-88,7
+96,15
@@
if (! window.XOSLIB_LOADED ) {
return errors;
}
// backbone.js semantics -- on successful validate, return nothing
return errors;
}
// backbone.js semantics -- on successful validate, return nothing
- }
+ },
+
+ /* uncommenting this would make validate() call xosValidate()
+ validate: function(attrs, options) {
+ r = this.xosValidate(attrs, options);
+ console.log("validate");
+ console.log(r);
+ return r;
+ }, */
});
XOSCollection = Backbone.Collection.extend({
});
XOSCollection = Backbone.Collection.extend({
@@
-295,10
+311,10
@@
if (! window.XOSLIB_LOADED ) {
for (key in attrs) {
value = attrs[key];
for (key in attrs) {
value = attrs[key];
- if ($.inArray(key, ["urlRoot", "modelName", "validate"])>=0) {
+ if ($.inArray(key, ["urlRoot", "modelName", "
collectionName", "
validate"])>=0) {
modelAttrs[key] = value;
}
modelAttrs[key] = value;
}
- if ($.inArray(key, ["urlRoot", "modelName", "relatedCollections", "foreignCollections"])>=0) {
+ if ($.inArray(key, ["urlRoot", "modelName", "
collectionName", "
relatedCollections", "foreignCollections"])>=0) {
collectionAttrs[key] = value;
}
}
collectionAttrs[key] = value;
}
}
diff --git
a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index
2eb3e42
..
28f85fd
100644
(file)
--- a/
planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/
planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@
-231,6
+231,7
@@
XOSDetailView = Marionette.ItemView.extend({
},
\r
\r
saveError: function(model, result, xhr, infoMsgId) {
\r
},
\r
\r
saveError: function(model, result, xhr, infoMsgId) {
\r
+ console.log("saveError");
\r
result["what"] = "save " + model.modelName + " " + model.attributes.humanReadableName;
\r
result["infoMsgId"] = infoMsgId;
\r
this.app.showError(result);
\r
result["what"] = "save " + model.modelName + " " + model.attributes.humanReadableName;
\r
result["infoMsgId"] = infoMsgId;
\r
this.app.showError(result);
\r
@@
-306,7
+307,6
@@
XOSDetailView = Marionette.ItemView.extend({
var infoMsgId = this.app.showInformational( {what: "save " + model.modelName + " " + model.attributes.humanReadableName, status: "", statusText: "in progress..."} );
\r
\r
this.model.save(data, {error: function(model, result, xhr) { that.saveError(model,result,xhr,infoMsgId);},
\r
var infoMsgId = this.app.showInformational( {what: "save " + model.modelName + " " + model.attributes.humanReadableName, status: "", statusText: "in progress..."} );
\r
\r
this.model.save(data, {error: function(model, result, xhr) { that.saveError(model,result,xhr,infoMsgId);},
\r
- invalid: function(model, result, xhr) { console.log("invalid!"); that.saveError(model,result,xhr,infoMsgId);},
\r
success: function(model, result, xhr) { that.saveSuccess(model,result,xhr,infoMsgId, isNew);}});
\r
/*if (isNew) {
\r
this.collection.add(this.model);
\r
success: function(model, result, xhr) { that.saveSuccess(model,result,xhr,infoMsgId, isNew);}});
\r
/*if (isNew) {
\r
this.collection.add(this.model);
\r
@@
-420,15
+420,9
@@
XOSItemView = Marionette.ItemView.extend({
tagName: 'tr',
className: 'test-tablerow',
tagName: 'tr',
className: 'test-tablerow',
- events: {"click": "changeItem"},
-
- changeItem: function(e) {
\r
- this.app.hideError();
\r
- e.preventDefault();
\r
- e.stopPropagation();
\r
-
\r
- this.app.navigateToModel(this.app, this.detailClass, this.detailNavLink, this.model);
\r
- },
\r
+ templateHelpers: function() { return { modelName: this.model.modelName,
+ collectionName: this.model.collectionName,
+ }},
});
/* XOSListView:
});
/* XOSListView:
diff --git
a/planetstack/core/xoslib/templates/xosAdmin.html
b/planetstack/core/xoslib/templates/xosAdmin.html
index
8e0448d
..
b032e00
100644
(file)
--- a/
planetstack/core/xoslib/templates/xosAdmin.html
+++ b/
planetstack/core/xoslib/templates/xosAdmin.html
@@
-90,6
+90,18
@@
</tr>
</script>
</tr>
</script>
+<script type="text/template" id="xos-delete-button-template">
+ <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
+</script>
+
+<script type="text/template" id="xos-delete-button-template">
+ <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
+</script>
+
+<script type="text/template" id="xos-detail-link-template">
+ <a href="#<%= collectionName %>/<%= id %>"><%= text %></a>
+</script>
+
<!-- Deployment -->
<script type="text/template" id="xosAdmin-deployment-list-template">
<!-- Deployment -->
<script type="text/template" id="xosAdmin-deployment-list-template">
@@
-102,6
+114,7
@@
<th>backend</th>
<th>admin_tenant</th>
<th># sites</th>
<th>backend</th>
<th>admin_tenant</th>
<th># sites</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
</tr></thead>
<tbody></tbody>
</table>
@@
-109,11
+122,12
@@
<script type="text/template" id="xosAdmin-deployment-listitem-template">
<script type="text/template" id="xosAdmin-deployment-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= backend_type %></td>
<td><%= admin_tenant %></td>
<td><%= typeof sites != 'undefined' && sites.length || 0 %></td>
<td><%= backend_type %></td>
<td><%= admin_tenant %></td>
<td><%= typeof sites != 'undefined' && sites.length || 0 %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-deployment-detail-template">
</script>
<script type="text/template" id="xosAdmin-deployment-detail-template">
@@
-146,8
+160,8
@@
</script>
<script type="text/template" id="xosAdmin-image-listitem-template">
</script>
<script type="text/template" id="xosAdmin-image-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= disk_format %></td>
<td><%= container_format %></td>
<td><%= path %></td>
<td><%= disk_format %></td>
<td><%= container_format %></td>
<td><%= path %></td>
@@
-186,8
+200,8
@@
<script type="text/template" id="xosAdmin-networkTemplate-listitem-template">
<script type="text/template" id="xosAdmin-networkTemplate-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= description %></td>
<td><%= visibility %></td>
<td><%= translation %></td>
<td><%= description %></td>
<td><%= visibility %></td>
<td><%= translation %></td>
@@
-229,8
+243,8
@@
</script>
<script type="text/template" id="xosAdmin-network-listitem-template">
</script>
<script type="text/template" id="xosAdmin-network-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= idToName(template,"networkTemplates","name") %></td>
<td><%= ports %></td>
<td><%= labels %></td>
<td><%= idToName(template,"networkTemplates","name") %></td>
<td><%= ports %></td>
<td><%= labels %></td>
@@
-269,7
+283,7
@@
</script>
<script type="text/template" id="xosAdmin-networkSliver-listitem-template">
</script>
<script type="text/template" id="xosAdmin-networkSliver-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= idToName(network,"networks","name") %></td>
<td><%= idToName(sliver,"slivers","name") %></td>
<td><%= ip %></td>
<td><%= idToName(network,"networks","name") %></td>
<td><%= idToName(sliver,"slivers","name") %></td>
<td><%= ip %></td>
@@
-306,7
+320,7
@@
</script>
<script type="text/template" id="xosAdmin-networkDeployment-listitem-template">
</script>
<script type="text/template" id="xosAdmin-networkDeployment-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= idToName(network,"networks","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= net_id %></td>
<td><%= idToName(network,"networks","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= net_id %></td>
@@
-342,8
+356,8
@@
<script type="text/template" id="xosAdmin-node-listitem-template">
<script type="text/template" id="xosAdmin-node-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= idToName(site,"sites","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
</script>
<td><%= idToName(site,"sites","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
</script>
@@
-376,7
+390,7
@@
<script type="text/template" id="xosAdmin-sliceRole-listitem-template">
<script type="text/template" id="xosAdmin-sliceRole-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= role %></td>
</script>
<td><%= role %></td>
</script>
@@
-410,8
+424,8
@@
<script type="text/template" id="xosAdmin-service-listitem-template">
<script type="text/template" id="xosAdmin-service-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= description %></td>
<td><%= enabled %></td>
<td><%= versionNumber %></td>
<td><%= description %></td>
<td><%= enabled %></td>
<td><%= versionNumber %></td>
@@
-450,8
+464,8
@@
</script>
<script type="text/template" id="xosAdmin-site-listitem-template">
</script>
<script type="text/template" id="xosAdmin-site-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= site_url %></td>
<td><%= enabled %></td>
<td><%= login_base %></td>
<td><%= site_url %></td>
<td><%= enabled %></td>
<td><%= login_base %></td>
@@
-496,8
+510,8
@@
</script>
<script type="text/template" id="xosAdmin-slice-listitem-template">
</script>
<script type="text/template" id="xosAdmin-slice-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= enabled %></td>
<td><%= omf_friendly %></td>
<td><%= description %></td>
<td><%= enabled %></td>
<td><%= omf_friendly %></td>
<td><%= description %></td>
@@
-539,7
+553,7
@@
</script>
<script type="text/template" id="xosAdmin-sliceDeployment-listitem-template">
</script>
<script type="text/template" id="xosAdmin-sliceDeployment-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= tenant_id %></td>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= tenant_id %></td>
@@
-574,7
+588,7
@@
</script>
<script type="text/template" id="xosAdmin-slicePrivilege-listitem-template">
</script>
<script type="text/template" id="xosAdmin-slicePrivilege-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(role,"sliceRoles","role") %></td>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(role,"sliceRoles","role") %></td>
@@
-617,8
+631,8
@@
<script type="text/template" id="xosAdmin-sliver-listitem-template">
<script type="text/template" id="xosAdmin-sliver-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= name
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name})
%></td>
<td><%= instance_id %></td>
<td><%= instance_name %></td>
<td><%= idToName(image,"images","name") %></td>
<td><%= instance_id %></td>
<td><%= instance_name %></td>
<td><%= idToName(image,"images","name") %></td>
@@
-667,8
+681,8
@@
<script type="text/template" id="xosAdmin-user-listitem-template">
<script type="text/template" id="xosAdmin-user-listitem-template">
- <td
class="objectLink"><%= id
%></td>
- <td
class="objectLink"><%= username
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: username})
%></td>
<td><%= firstname %></td>
<td><%= lastname %></td>
<td><%= phone %></td>
<td><%= firstname %></td>
<td><%= lastname %></td>
<td><%= phone %></td>
@@
-708,7
+722,7
@@
</script>
<script type="text/template" id="xosAdmin-userDeployment-listitem-template">
</script>
<script type="text/template" id="xosAdmin-userDeployment-listitem-template">
- <td
class="objectLink"><%= id
%></td>
+ <td
> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id})
%></td>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= kuser_id %></td>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= kuser_id %></td>
@@
-729,4
+743,6
@@
<script>
xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
xosInlineListButtonsTemplate = _.template($("#xos-inline-list-buttons-template").html());
<script>
xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
xosInlineListButtonsTemplate = _.template($("#xos-inline-list-buttons-template").html());
+xosDeleteButtonTemplate = _.template($("#xos-delete-button-template").html());
+xosDetailLinkTemplate = _.template($("#xos-detail-link-template").html());
</script>
</script>