forked from DGNum/gestioCOF
Clarity
This commit is contained in:
parent
f901ea9396
commit
a984d1fd6f
3 changed files with 9 additions and 9 deletions
|
@ -17,7 +17,8 @@ var Account = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
reset: function () {
|
||||
// On n'utilise pas .clear() car on ne veut pas clear le trigramme
|
||||
// Réinitialise les attributs du modèle à leurs défaults, sauf le trigramme qui est bind à l'input.
|
||||
// On n'utilise pas .clear() car on ne veut pas clear le trigramme.
|
||||
this.set(this.defaults)
|
||||
},
|
||||
|
||||
|
@ -30,7 +31,7 @@ var Account = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
view: function () {
|
||||
if (!this.is_valid()) {
|
||||
if (!this.is_empty_account()) {
|
||||
view_class = EmptyAccountView
|
||||
} else if (this.get("trigramme") == 'LIQ') {
|
||||
view_class = LIQView
|
||||
|
@ -44,7 +45,7 @@ var Account = Backbone.Model.extend({
|
|||
this.view().render();
|
||||
},
|
||||
|
||||
is_valid: function () {
|
||||
is_empty_account: function () {
|
||||
return (this.id != 0)
|
||||
},
|
||||
})
|
||||
|
@ -132,7 +133,7 @@ var EmptyAccountView = AccountView.extend({
|
|||
le compte est invalide */
|
||||
buttons = '<button class="btn btn-primary search" title="Rechercher"><span class="glyphicon glyphicon-search"></span></button>';
|
||||
trigramme = this.model.get("trigramme")
|
||||
if (trigramme.is_valid_tri()) {
|
||||
if (trigramme.is_valid_trigramme()) {
|
||||
trigramme = encodeURIComponent(trigramme);
|
||||
var url_base = django_urls["kfet.account.create"]();
|
||||
var url = `${url_base}?trigramme=${trigramme}`;
|
||||
|
|
|
@ -6,7 +6,7 @@ String.prototype.format_trigramme = function () {
|
|||
return this.toUpperCase().substr(0, 3)
|
||||
}
|
||||
|
||||
String.prototype.is_valid_tri = function () {
|
||||
String.prototype.is_valid_trigramme = function () {
|
||||
var pattern = /^[^a-z]{3}$/;
|
||||
return pattern.test(this);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ class AccountManager {
|
|||
|
||||
// Raccourci LIQ
|
||||
this._$input.on("keydown", function (e) {
|
||||
// keycode 40: Down Arrow
|
||||
if (e.keyCode == 40) {
|
||||
if (e.key == "ArrowDown") {
|
||||
that.set("LIQ")
|
||||
}
|
||||
})
|
||||
|
@ -39,7 +38,7 @@ class AccountManager {
|
|||
});
|
||||
|
||||
this._$container.on('keydown', function (e) {
|
||||
if (e.which == 70 && e.ctrlKey) {
|
||||
if (e.key == "f" && e.ctrlKey) {
|
||||
// Ctrl + F : universal search shortcut
|
||||
that.search.open();
|
||||
e.preventDefault();
|
||||
|
@ -55,7 +54,7 @@ class AccountManager {
|
|||
update() {
|
||||
var trigramme = this._$input.val().format_trigramme();
|
||||
this.account.set({ "trigramme": trigramme })
|
||||
if (trigramme.is_valid_tri()) {
|
||||
if (trigramme.is_valid_trigramme()) {
|
||||
this.account.fetch({
|
||||
"success": this._on_success.bind(this),
|
||||
"error": this.reset.bind(this, false),
|
||||
|
|
Loading…
Reference in a new issue