diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js
index 6493bb5c..3719042e 100644
--- a/kfet/static/kfet/js/history.js
+++ b/kfet/static/kfet/js/history.js
@@ -1,6 +1,6 @@
class History {
- constructor() {
+ constructor(api_options, display_options) {
this.templates = {
'purchase': '
',
'specialope': '
',
@@ -11,14 +11,12 @@ class History {
};
this._$container = $('#history');
+ this._$nb_opes = $('#nb_opes');
this.list = new OperationList();
- this.api_options = {
- 'from': moment().subtract(3, 'days').format('YYYY-MM-DD HH:mm:ss'),
- };
-
- this.display_options = {} ;
- this.lock = 0 ;
+ this.api_options =
+ api_options || { from: moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss'), };
+ this.display_options = display_options || {};
this._init_selection();
this._init_events();
@@ -26,6 +24,8 @@ class History {
display() {
this.list.display(this._$container, this.templates, this.display_options);
+ var nb_opes = this._$container.find('.ope[canceled="false"]').length;
+ $('#nb_opes').text(nb_opes);
}
reset() {
@@ -70,10 +70,11 @@ class History {
}
//TODO: permission management in another class ?
+ //TODO: idem for confirmation
cancel_operations(to_cancel, password='') {
- if (this.lock == 1)
+ if (lock == 1)
return false;
- this.lock = 1;
+ lock = 1;
var that = this;
if (window.kpsul) {
@@ -100,7 +101,7 @@ class History {
})
.done(function(data) {
on_success();
- that.lock = 0;
+ lock = 0;
})
.fail(function($xhr) {
var data = $xhr.responseJSON;
@@ -114,7 +115,7 @@ class History {
displayErrors(getErrorsHtml(data));
break;
}
- that.lock = 0;
+ lock = 0;
});
}
@@ -167,5 +168,8 @@ class History {
this.add_node(opegroup);
}
}
+
+ var nb_opes = this._$container.find('.ope[canceled="false"]').length;
+ $('#nb_opes').text(nb_opes);
}
}
diff --git a/kfet/static/kfet/js/kfet.api.js b/kfet/static/kfet/js/kfet.api.js
index 8db9b0fe..1b6e40fc 100644
--- a/kfet/static/kfet/js/kfet.api.js
+++ b/kfet/static/kfet/js/kfet.api.js
@@ -1087,12 +1087,17 @@ class APIModelForest extends ModelForest {
api_options['format'] = 'json';
- $.getJSON(this.constructor.url_model, api_options)
- .done(function(json, textStatus, jqXHR) {
- that.from(json);
- on_success(json, textStatus, jqXHR);
- })
- .fail(on_error);
+ $.ajax({
+ dataType: "json",
+ url : this.constructor.url_model,
+ method : "POST",
+ data : api_options,
+ })
+ .done(function(json, textStatus, jqXHR) {
+ that.from(json);
+ on_success(json, textStatus, jqXHR);
+ })
+ .fail(on_error);
}
}
@@ -1244,6 +1249,9 @@ class Formatter {
var props = options.override_props ? options.props : this.props.concat(options.props);
var attrs = options.override_attrs ? options.attrs : this.attrs.concat(options.attrs);
+ props = options.remove_props ? props.diff(options.remove_props) : props;
+ attrs = options.remove_attrs ? props.diff(options.remove_attrs) : attrs;
+
var prefix_prop = options.prefix_prop !== undefined ? options.prefix_prop : '.';
var prefix_attr = options.prefix_attr !== undefined ? options.prefix_attr : '';
diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js
index aa58d1ce..9c5326c7 100644
--- a/kfet/static/kfet/js/kfet.js
+++ b/kfet/static/kfet/js/kfet.js
@@ -24,6 +24,36 @@ String.prototype.isValidTri = function() {
return pattern.test(this);
}
+/**
+ * Array method
+ * @global
+ * @return {[]} Array elements not in given argument
+ */
+// Note : we define it this way to avoid problems in for loops
+Object.defineProperty(Array.prototype, 'diff', {
+ enumerable: false,
+ configurable: true,
+ value: function(a) {
+ return this.filter(function (elt) {
+ return a.indexOf(elt) < 0 ;
+ });
+ }
+});
+
+
+/**
+ * Checks if given argument is float ;
+ * if not, parses given argument to float value.
+ * @global
+ * @return {float}
+ */
+function floatCheck(v) {
+ if (typeof v === 'number')
+ return v;
+ return Number.parseFloat(v);
+}
+
+
$(document).ready(function() {
$(window).scroll(function() {
diff --git a/kfet/static/kfet/js/kpsul.js b/kfet/static/kfet/js/kpsul.js
index c11e78dc..90ff988e 100644
--- a/kfet/static/kfet/js/kpsul.js
+++ b/kfet/static/kfet/js/kpsul.js
@@ -5,8 +5,7 @@ class KPsulManager {
this.account_manager = new AccountManager(this);
this.checkout_manager = new CheckoutManager(this);
this.article_manager = new ArticleManager(this);
- this.history = new History(this);
- this.lock = 0 ;
+ this.history = new History();
}
reset(soft) {
diff --git a/kfet/templates/kfet/history.html b/kfet/templates/kfet/history.html
index 78f8ddea..64ccf23d 100644
--- a/kfet/templates/kfet/history.html
+++ b/kfet/templates/kfet/history.html
@@ -15,7 +15,9 @@
+
+
{% endblock %}
@@ -61,11 +63,12 @@
diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html
index e12e836d..45b50905 100644
--- a/kfet/templates/kfet/kpsul.html
+++ b/kfet/templates/kfet/kpsul.html
@@ -167,27 +167,6 @@
{% csrf_token %}