Laravel - Extend Vue.js in Custom Extension
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Laravel - Extend Vue.js in Custom Extension
Hello again,
So, I was making few changes in Stock Section of Product Edit form. So, I have added another field for stock.
And want to sum up both stocks using JavaScript. So, I added some code in Vue.js file, i.e. product.js file inside themes directory. Here is the complete path:
./ext/ai-admin-jqadm/admin/jqadm/themes/product.js
It is working fine but I think as it is a custom code, therefore, I should put it under my extension like the path below:
./ext/myextension/admin/jqadm/themes/product.js
But when I do it, the sum up functionality doesn't work. Below is my modified product.js file code, which I added:
totalStock is the function that I added. Can anyone guide me how to extend Vue.js files?
Thanks!
So, I was making few changes in Stock Section of Product Edit form. So, I have added another field for stock.
And want to sum up both stocks using JavaScript. So, I added some code in Vue.js file, i.e. product.js file inside themes directory. Here is the complete path:
./ext/ai-admin-jqadm/admin/jqadm/themes/product.js
It is working fine but I think as it is a custom code, therefore, I should put it under my extension like the path below:
./ext/myextension/admin/jqadm/themes/product.js
But when I do it, the sum up functionality doesn't work. Below is my modified product.js file code, which I added:
Code: Select all
Aimeos.Product.Stock = {
init : function() {
this.vstock = new Vue({
'el': '.item-stock .stock-list',
'data': {
'items': $(".item-stock .stock-list").data("items"),
'keys': $(".item-stock .stock-list").data("keys"),
'prefix': $(".item-stock .stock-list").data("prefix"),
'siteid': $(".item-stock .stock-list").data("siteid"),
'numtypes': $(".item-stock .stock-list").data("numtypes")
},
methods: {
checkSite : function(key, idx) {
return this.items[key][idx] != this.siteid;
},
totalStock : function() {
var totalStock = 0;
for(var key in this.items['stock.stocklevel']) {
if(!isNaN(parseInt(this.items['stock.stocklevel'][key])))
totalStock += parseInt(this.items['stock.stocklevel'][key]);
console.log(totalStock);
}
$('.item-stocktotal').val(totalStock);
},
addItem : function() {
var idx = (this.items[this.prefix + 'id'] || []).length;
for(var key in this.keys) {
key = this.keys[key]; this.$set(this.items, key, (this.items[key] || []).concat(['']));
}
this.$set(this.items[this.prefix + 'siteid'], idx, this.siteid);
this.numtypes--;
},
removeItem : function(idx) {
for(key in this.items) {
this.items[key].splice(idx, 1);
}
this.numtypes++;
}
}
});
this.vstock.totalStock()
}
};
Thanks!
Re: Laravel - Extend Vue.js in Custom Extension
I think the only way to do it is to contribute to ai-admin-jqadm: https://github.com/aimeos/ai-admin-jqadm
Re: Laravel - Extend Vue.js in Custom Extension
You can overwrite anything in Aimeos besides PHP base classes
Just put your JS code in the ./ext/myextension/themes/admin/jqadm/custom.js:
https://aimeos.org/docs/latest/admin/jqadm/customize/
Just put your JS code in the ./ext/myextension/themes/admin/jqadm/custom.js:
https://aimeos.org/docs/latest/admin/jqadm/customize/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Laravel - Extend Vue.js in Custom Extension
I will try!
Thank you!
Thank you!