improved usage of var/let/const; fixed error on removing row
This commit is contained in:
parent
b5f0c1db79
commit
5d9923bf30
|
|
@ -358,7 +358,6 @@
|
|||
},
|
||||
|
||||
created: function () {
|
||||
console.log(this.optionRows);
|
||||
var this_this = this;
|
||||
|
||||
$(document).ready(function () {
|
||||
|
|
@ -374,9 +373,9 @@
|
|||
|
||||
methods: {
|
||||
addOptionRow: function (isNullOptionRow) {
|
||||
var rowCount = this.optionRowCount++;
|
||||
let id = 'option_' + rowCount;
|
||||
var row = {'id': id};
|
||||
const rowCount = this.optionRowCount++;
|
||||
const id = 'option_' + rowCount;
|
||||
let row = {'id': id};
|
||||
|
||||
@foreach (app('Webkul\Core\Repositories\LocaleRepository')->all() as $locale)
|
||||
row['{{ $locale->code }}'] = '';
|
||||
|
|
@ -395,9 +394,10 @@
|
|||
removeRow: function (row) {
|
||||
if (row.id === this.idNullOption) {
|
||||
this.idNullOption = null;
|
||||
this.isNullOptionChecked = false;
|
||||
}
|
||||
|
||||
var index = this.optionRows.indexOf(row);
|
||||
const index = this.optionRows.indexOf(row);
|
||||
Vue.delete(this.optionRows, index);
|
||||
},
|
||||
|
||||
|
|
@ -426,9 +426,11 @@
|
|||
watch: {
|
||||
isNullOptionChecked: function (val) {
|
||||
if (val) {
|
||||
this.addOptionRow(true);
|
||||
} else {
|
||||
let row = this.optionRows.find(optionRow => optionRow.id === this.idNullOption);
|
||||
if (! this.idNullOption) {
|
||||
this.addOptionRow(true);
|
||||
}
|
||||
} else if(this.idNullOption !== null && typeof this.idNullOption !== 'undefined') {
|
||||
const row = this.optionRows.find(optionRow => optionRow.id === this.idNullOption);
|
||||
this.removeRow(row);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,9 +451,9 @@
|
|||
|
||||
methods: {
|
||||
addOptionRow: function (isNullOptionRow) {
|
||||
var rowCount = this.optionRowCount++;
|
||||
let id = 'option_' + rowCount;
|
||||
var row = {'id': id};
|
||||
const rowCount = this.optionRowCount++;
|
||||
const id = 'option_' + rowCount;
|
||||
let row = {'id': id};
|
||||
|
||||
@foreach (app('Webkul\Core\Repositories\LocaleRepository')->all() as $locale)
|
||||
row['{{ $locale->code }}'] = '';
|
||||
|
|
@ -472,9 +472,10 @@
|
|||
removeRow: function (row) {
|
||||
if (row.id === this.idNullOption) {
|
||||
this.idNullOption = null;
|
||||
this.isNullOptionChecked = false;
|
||||
}
|
||||
|
||||
var index = this.optionRows.indexOf(row)
|
||||
const index = this.optionRows.indexOf(row)
|
||||
Vue.delete(this.optionRows, index);
|
||||
},
|
||||
|
||||
|
|
@ -505,8 +506,8 @@
|
|||
if (! this.idNullOption) {
|
||||
this.addOptionRow(true);
|
||||
}
|
||||
} else {
|
||||
let row = this.optionRows.find(optionRow => optionRow.id === this.idNullOption);
|
||||
} else if(this.idNullOption !== null && typeof this.idNullOption !== 'undefined') {
|
||||
const row = this.optionRows.find(optionRow => optionRow.id === this.idNullOption);
|
||||
this.removeRow(row);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue