I have used "Karenderia Multiple Restaurant System". I want to add an extra option to Food item. For that i have done this as bellow.
Added to food-item-add.php
<div class="uk-form-row">
<label class="uk-form-label uk-h3"><?php echo t("Food Type")?></label>
<div class="clear"></div>
<ul class="uk-list uk-list-striped">
<li>
<?php
if(!isset($data['non_veg'])){
$data['non_veg']='';
}
echo CHtml::checkBox('non_veg',
$data['non_veg']==2?true:false
,array(
'class'=>"icheck",
'value'=>2
))?>
<?php echo t("Non Veg")?>
</li>
</ul>
</div>
After that i have added this in AjaxAdmin.php to FoodItemAdd function, which action in the admin.js
'non_veg'=>isset($this->data['non_veg'])?$this->data['non_veg']:1,
After that i have added to the table_structure.php to "CREATE TABLE IF NOT EXISTS ".$table_prefix."item"
`non_veg` int(1) NOT NULL DEFAULT '1',
Now, I want to add the option to an item. But i am getting the a ajax error like this
Uncaught ReferenceError: data is not defined
at Object.error (admin.js?ver=1:290)
at c (jquery-1.10.2.min.js:4)
at Object.fireWith [as rejectWith] (jquery-1.10.2.min.js:4)
at k (jquery-1.10.2.min.js:6)
at XMLHttpRequest.r (jquery-1.10.2.min.js
Can i know where is the problem to add an option ?
Actually i have done everything right. But it not saved in the DB. So i have added a col with the name. Now it is saved.
Thank you.
Related
I want to generate a warning near ADDTOCART when the ADDTOCART button clicked on odoo website.
XML file:
<t t-if="website.get_promo_code_error(delete=False)">
<div class="card bg-danger text-white mt16">
<div class="card-header clearfix">
<span class="float-left"><t t-esc="website.get_promo_code_error()" /></span>
</div>
</div>
</t>
Controler:
request.session['error_promo_code'] = "Can not add"
return request.redirect("/shop/product/%s" % product.id)
model:
def get_promo_code_error(self, delete=True):
error = request.session.get('error_promo_code')
if error and delete:
request.session.pop('error_promo_code')
return error
In Odoo there is a default feature which provides on the website.
Goto Product -> Ecommerce tab -> there you find field Availability-> select this option
Show inventory below a threshold and prevent sales if not enough stock
It will allow you to add the Availability Threshold, Add your product stock value like 10.
When you go on the webshop and add more than 10 qty for the same product it will trigger the message near the add to cart button.
I have tried / guessed at every combination of v-bind/v-model/:checked/:value I can think of, but I can't get these damn checkboxes checked on load:
Using Vue Material / Vue3:
<div v-if="items.length">
<div
v-for="(value,key,index) in this.items"
:key="index"
:ref="'icon'+items[key].id">
<md-checkbox
:id="'TDS'+key"
v-model="items[key].complete"
true-value="1"
#change="doDo(items[key].id)"
class="md-primary m-0"
>
{{ items[key].item }} {{items[key].complete}}
</md-checkbox>
</div>
</div>
The bit I can't figure out is how to make the checkbox checked if items[key].complete=1 when data is loaded.
You are already inside the loop
v-model="value.complete"
Same goes for all other bindings.
And your data should not be accessed with this in your template
v-for="(value,key,index) in items"
This one should already work, if you receive your data properly, it may update itself due to reactivity. Maybe try v-model="!!items[key].complete" just to be sure that your value is coerced to a Boolean.
I'm using a UIKit library for a tab component that listens to a uk-tab property that targets an id. The problem with this, is that it creates the same ID for every tabbed component. I like the UI, but whoever thought of this, didn't think too far into it. I could fix it by making the id dynamic but I am having trouble calling it in the uk-tab property because it is rendering a string. Coming from a react background, I would do a string literal and some JSX, something like #item-${_id}to show #item-12, #item-13....and so on. But That's not working. How can I do this in Vue?
Here is an example of how it works
<div class="mytrigger">
<ul uk-tab="connect: #component-tab-left; animation: uk-animation-fade">
</div>
<div class="mytargetedtab">
<ul id="component-tab-left" class="uk-switcher">
</div>
Here is an example of how what I need
<div class="mytrigger">
<ul uk-tab="connect: #_uid+'switcher'; animation: uk-animation-fade">
</div>
<div class="mytargetedtab">
<ul :id="_uid+'switcher'" class="uk-switcher">
</div>
Check out the dev tools. It should be 810switcher, but instead is taking it as a string
Any ideas? Thanks
I believe what you need is:
<ul :uk-tab="`connect: #${_uid}switcher; animation: uk-animation-fade`">
Or if you prefer not to use backticks:
<ul :uk-tab="'connect: #' + _uid + 'switcher; animation: uk-animation-fade'">
The output will be:
<ul uk-tab="connect: #22switcher; animation: uk-animation-fade">
A few notes:
Using a : is short for v-bind: but don't let the name confuse you. v-bind doesn't necessarily bind anything, it just makes the attribute value a JavaScript expression.
I'd avoid using numbers at the start of element ids, I've seen that cause problems in the past. It'd be better to put the numbers at the end.
The underscore at the start of _uid indicates that it's private to Vue. There are no guarantees about what form it will take or whether it will even exist going forward.
Use data-uk-tab instead of uk-tab like below.
<div class="mytrigger">
<ul data-uk-tab="{connect: `#${_uid}switcher`, animation: 'uk-animation-fade'}">
</div>
<div class="mytargetedtab">
<ul :id="_uid+'switcher'" class="uk-switcher">
</div>
For more information => Switcher with tabs
You can use any javascript expression in a data binding in vue. So, if you bind a string template to the attribute, it'll populate what you expect.
<ul :uk-tab="`connect: #${uid}switcher`'; animation: uk-animation-fade">
Is there a way in Aurelia to say 'If x == this, then show this'?
To be specific, I have an array of data that looks something like this:
[
{objectID: 1, customDataArray: [1,2,3,4], customDataType: { cdt: "Troops" }}
]
This array obviously has multiple rows that look like the one above where it's passing me an array of custom values that I need to reference. Those values could be the IDs of different 'groups' in our system. That's why we are passing in an object the contains what type of custom data it is. e.g. "Troops"
So what's happening is on Activate, I'm fetching all this data from my API and storing it in a variable. Well based on whether the custom data type is "Troops" or something else, I want to show a different input label. For example, if it is "Troops," I want to show a label that says "input troop id's" and so on.
Also, sometimes the customDataType isn't required so it comes in as null. So in that case, I want to show something different. Not sure how to handle this one..
The if custom attribute or the show custom attribute would work. Unfortunately, we don't have a switch or else type of setup.
<label if.bind="p.customDataType.cdt === 'Troops'">Input Troop Ids</label>
<label if.bind="p.customDataType.cdt !== 'Troops'">Something Different</label>
You could try if if.bind could be useful for this, as below:
<ul>
<li repeat.for="obj of data" if.bind="obj.customDataType">
<span>${obj.customDataType.cdt}</span> -
<strong repeat.for="cda of obj.customDataArray">${cda}, </strong>
</li>
<li repeat.for="obj of data" if.bind="!obj.customDataType">
<span>No CustomDataType</span>
<strong repeat.for="cda of obj.customDataArray">${cda}, </strong>
</li>
</ul>
Here is a plunker that shows this in action: https://gist.run/?id=21991c490810a4acf2e38cec99614bbd
Just a simple question, is it possible to change the classname generated by ClistView ?
by default, it generates
<div class="post">
for all the list.
I'd like to have
<div class=post1>
<div class=post2>
...
You can customize CListView styles with bellow parameters:
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$YOUR_DATA_PROVIDET,
'itemView'=>'...',
'sortableAttributes'=>array(),
'cssFile'=>' YOU CAN ASSIGN A CSS FILE TO YOUR CLISTVIEW',
'itemsCssClass'=>'SOME CLASS',
'pagerCssClass'=>'SOME CLASS',
'sorterCssClass'=>'SOME CLASS',
'summaryCssClass'=>'SOME CLASS',
));
for more information you can check CListView's Official document in the following link:
CListView
UPDATE:
If you want to change other names, you must edit the source of yii's CGridView. But changing the style of it could be more easier.
If you want a different, incrementing class on each looped list item, change your itemView partial like this:
using the ID of each model:
<div class="post<?php print $data->id; ?>">
<?php
print_r($data->attributes); // Or whatever
?>
</div>
using the 'index' of the current iteration:
<div class="post<?php print $index; ?>">
<?php
print_r($data->attributes); // Or whatever
?>
</div>
More info available here