mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Use backbone to display taskmanager front end
This commit is contained in:
66
www/scripts/apps/admin/tasks-manager/views/task.js
Normal file
66
www/scripts/apps/admin/tasks-manager/views/task.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"backbone"
|
||||
], function ($, _, Backbone) {
|
||||
var TaskView = Backbone.View.extend({
|
||||
initialize: function () {
|
||||
this.template = _.template($('#task_template').html());
|
||||
// render only parts of the model
|
||||
this.model.on('change:id', this.renderId, this);
|
||||
this.model.on('change:configuration', this.renderConfiguration, this);
|
||||
this.model.on('change:actual', this.renderActual, this);
|
||||
this.model.on('change:process-id', this.renderPid, this);
|
||||
this.model.on('change:name', this.renderName, this);
|
||||
},
|
||||
events: {
|
||||
"click a": "clickAction"
|
||||
},
|
||||
tagName: "tr",
|
||||
render: function () {
|
||||
this.$el.html(this.template({'task':this.model.toJSON()}));
|
||||
return this;
|
||||
},
|
||||
renderId: function () {
|
||||
$(".idTask", this.$el).html(this.model.get("id"));
|
||||
return this;
|
||||
},
|
||||
renderConfiguration: function () {
|
||||
$(".confTask", this.$el).html(this.model.get("configuration"));
|
||||
return this;
|
||||
},
|
||||
renderActual: function () {
|
||||
$(".actualTask", this.$el).html(this.model.get("actual"));
|
||||
return this;
|
||||
},
|
||||
renderPid: function () {
|
||||
$(".pidTask", this.$el).html(this.model.get("process-id"));
|
||||
return this;
|
||||
},
|
||||
renderName: function () {
|
||||
$(".nameTask", this.$el).html(this.model.get("name"));
|
||||
return this;
|
||||
},
|
||||
clickAction: function(e) {
|
||||
e.preventDefault();
|
||||
var link = $(e.target);
|
||||
var url = link.attr('href');
|
||||
|
||||
if(url && url.indexOf('#') !== 0) {
|
||||
// This is defined in admin/index.html.twig
|
||||
window.loadRightAjax(url, link.attr("method") || "GET");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return TaskView;
|
||||
});
|
Reference in New Issue
Block a user