diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js
index 772ac1bf..a5f0bccc 100644
--- a/kfet/static/kfet/js/history.js
+++ b/kfet/static/kfet/js/history.js
@@ -22,40 +22,42 @@ class KHistory {
constructor(options) {
var all_options = $.extend({}, this.constructor.default_options, options);
-
- this.templates = all_options.templates;
this.api_options = all_options.api_options;
this._$container = $('#history');
this._$nb_opes = $('#nb_opes');
- this.list = new OperationList();
+ this.data = new OperationList();
if (!all_options.no_select)
this.selection = new KHistorySelection(this);
+ var templates = all_options.templates
if (all_options.no_trigramme)
- this.templates['opegroup'] = '
'
+ templates['opegroup'] =
+ '
';
+
+ this.display = new ForestDisplay(this._$container, templates);
this._init_events();
}
fetch(api_options) {
- this.list.clear();
+ this.data.clear();
if (api_options)
this.api_options = api_options;
- this.list.fromAPI(this.api_options)
- .done( () => this.display() );
+ this.data.fromAPI(this.api_options)
+ .done( () => this.display_data() );
}
- display() {
- this._$container.html('');
- this.list.display(this._$container, this.templates, {});
+ display_data() {
+ this.display.clear();
+ this.display.render(this.data);
var nb_opes = this._$container.find('.ope[canceled="false"]').length;
- $('#nb_opes').text(nb_opes);
+ this._$nb_opes.text(nb_opes);
}
_init_events() {
@@ -82,20 +84,16 @@ class KHistory {
}
add_node(data) {
- var node = this.list.get_or_create(data.modelname, data.content, 0);
- this.list.add_to_container(this._$container, node, this.templates);
+ var node = this.data.get_or_create(data.modelname, data.content, 0);
+ this.display.add(node);
}
- update_node(type, id, update_data) {
- var to_update = this.list.find(type, id);
- if (!to_update)
+ update_node(modelname, id, update_data) {
+ var updated = this.data.update(modelname, id, update_data)
+ if (!updated)
return false;
- to_update.update(update_data);
- var $new_elt = to_update.display($(this.templates[type]), {});
-
- var $to_replace = this._$container.find('#'+type+'-'+id+'>:first-child');
- $to_replace.replaceWith($new_elt);
+ this.display.update(updated);
return true;
}