1
0
Fork 0

Cleanup foxxActiveView

This commit is contained in:
Lucas Dohmen 2014-12-11 21:48:49 +01:00 committed by Michael Hackstein
parent 111b89f1c6
commit 89b2283423
1 changed files with 4 additions and 76 deletions

View File

@ -3,86 +3,17 @@
/*global Backbone, $, window, EJS, arangoHelper, _, templateEngine, Joi*/
(function() {
"use strict";
var checkMount = function(mount) {
var regex = /^(\/[^\/\s]+)+$/;
if (!regex.test(mount)){
arangoHelper.arangoError("Please give a valid mount point, e.g.: /myPath");
return false;
}
return true;
};
'use strict';
window.FoxxActiveView = Backbone.View.extend({
tagName: 'div',
className: "tile",
template: templateEngine.createTemplate("foxxActiveView.ejs"),
className: 'tile',
template: templateEngine.createTemplate('foxxActiveView.ejs'),
events: {
'click' : 'openAppDetailView'
},
initialize: function(){
this._show = true;
var mount = this.model.get("mount");
var isSystem = (
this.model.get("isSystem") &&
mount.charAt(0) === '/' &&
mount.charAt(1) === '_'
);
if (isSystem) {
this.buttonConfig = [];
} else {
this.buttonConfig = [
window.modalView.createDeleteButton(
"Uninstall", this.uninstall.bind(this)
),
window.modalView.createSuccessButton(
"Save", this.changeFoxx.bind(this)
)
];
}
this.showMod = window.modalView.show.bind(
window.modalView,
"modalTable.ejs",
"Modify Application"
);
this.appsView = this.options.appsView;
_.bindAll(this, 'render');
},
changeFoxx: function() {
var mount = $("#change-mount-point").val();
var failed = false;
var app = this.model.get("app");
var prefix = this.model.get("options").collectionPrefix;
if (mount !== this.model.get("mount")) {
if (checkMount(mount)) {
$.ajax("foxx/move/" + this.model.get("_key"), {
async: false,
type: "PUT",
data: JSON.stringify({
mount: mount,
app: app,
prefix: prefix
}),
dataType: "json",
error: function(data) {
failed = true;
arangoHelper.arangoError(data.responseText);
}
});
} else {
return;
}
}
// TO_DO change version
if (!failed) {
window.modalView.hide();
this.appsView.reload();
}
},
openAppDetailView: function() {
// var url = window.location.origin + "/_db/" +
// encodeURIComponent(arangoHelper.currentDatabase()) +
@ -92,10 +23,7 @@
},
render: function(){
if (this._show) {
$(this.el).html(this.template.render(this.model));
}
$(this.el).html(this.template.render(this.model));
return $(this.el);
}
});