ionic 2 Prompts alert - ionic2

how to insert radio button and text input inside Prompts alert in ionic 2.
it's work only with text input or radio button. but i want to add radio button group with radio buttons to select only one option and text input in one alert prompt.
my coding
let prompt = this.alertCtrl.create({
title: 'Add Course',
message: "Enter Course Detailes",
inputs: [
{
name: 'id',
placeholder: 'Course ID'
},
{
name: 'img',
placeholder: 'Image url'
},
{
name: 'title',
placeholder: 'Title'
},
{
name: 'Details',
placeholder: 'Details'
},
{
type:'radio',
label:'something1',
value:'something1'
},
{
type:'radio',
label:'something2',
value:'something2'
}
],
buttons : [
{
text: "Cancel",
handler: data => {
console.log("cancel clicked");
}
},
{
text: "Save",
handler: data => {
console.log("search clicked");
}
}
]
});
prompt.present();

According to the documentation:
Radios, checkboxes and text inputs are all accepted, but they cannot be mixed. For example, an alert could have all radio button inputs, or all checkbox inputs, but the same alert cannot mix radio and checkbox inputs.
You should use a separate component with a modal controller
#Component(...)
class AddCourses {
courseForm:FormGroup
constructor(params: NavParams) {
}
//create the form reactive or template driven
}
In your parent page,
let coursesModal = this.modalCtrl.create(AddCourses, data);
coursesModal.present();

Related

Issue regarding the did select in the list card(actions on google)

I am developing a shopping bot where the user asks for a product and they are displaying in the list cards dynamically from the database.
Here my question is how to get the option of what the user selects in the list of items. Attaching the code and screenshots of my console.
function did_select(conv, input, option)
{
console.log("option",conv);
const param = conv.getArgument('OPTION');
console.log("param",param);
for(var i = 0;i<=temparray1.length;i++)
{
if (option === temparray1[i]) {
conv.close('Number one is a great choice!')
}
}
}
Please help me out,
Thnx Ramya.
When you sent the list, you specified an "option key" for each of the items in the list. These keys are strings that will be sent back based on what the user selects. If you sent the list using something like this
app.intent('List', (conv) => {
if (!conv.screen) {
conv.ask('Sorry, try this on a screen device or select the ' +
'phone surface in the simulator.');
return;
}
conv.ask('This is a list example.');
// Create a list
conv.ask(new List({
title: 'List Title',
items: {
// Add the first item to the list
'SELECTION_KEY_ONE': {
synonyms: [
'synonym 1',
'synonym 2',
'synonym 3',
],
title: 'Title of First List Item',
description: 'This is a description of a list item.',
image: new Image({
url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
alt: 'Image alternate text',
}),
},
// Add the second item to the list
'SELECTION_KEY_GOOGLE_HOME': {
synonyms: [
'Google Home Assistant',
'Assistant on the Google Home',
],
title: 'Google Home',
description: 'Google Home is a voice-activated speaker powered by ' +
'the Google Assistant.',
image: new Image({
url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
alt: 'Google Home',
}),
},
// Add the third item to the list
'SELECTION_KEY_GOOGLE_PIXEL': {
synonyms: [
'Google Pixel XL',
'Pixel',
'Pixel XL',
],
title: 'Google Pixel',
description: 'Pixel. Phone by Google.',
image: new Image({
url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
alt: 'Google Pixel',
}),
},
},
}));
});
Then you would have three keys:
SELECTION_KEY_ONE
SELECTION_KEY_GOOGLE_HOME
SELECTION_KEY_GOOGLE_PIXEL
One of these would be returned to you in the option parameter of your handler method. So your handler might look something like
var temparray1 = [
'SELECTION_KEY_ONE',
'SELECTION_KEY_GOOGLE_HOME',
'SELECTION_KEY_GOOGLE_PIXEL'
];
function did_select(conv, input, option)
{
console.log("option",option);
for(var i = 0;i<=temparray1.length;i++)
{
if (option === temparray1[i]) {
conv.close('Number '+(i+1)+' is a great choice!')
}
}
}

How to remove the delete button from the calendar wizard in Odoo 10?

I am working with Odoo10. If I go to Sales > Lead > Meeting Button and I click on the meeting button the calendar view is opened. You can open the view by creating a meeting in the calendar as well. The model used by the popup window is calendar.event.
These buttons appear in the wizard: "Save", "Delete", "Cancel". The wizard does not contain the code of "Delete" button in the standard view.
So how can I remove the "Delete" button in that popup?
I have checked that the button is created by JavaScript. You just need to override the method. Follow the Odoo documentation guidelines. Use extend or include to override it
var CalendarView = View.extend({
// [...]
open_event: function(id, title) {
var self = this;
if (! this.open_popup_action) {
var index = this.dataset.get_id_index(id);
this.dataset.index = index;
if (this.write_right) {
this.do_switch_view('form', { mode: "edit" });
} else {
this.do_switch_view('form', { mode: "view" });
}
}
else {
new form_common.FormViewDialog(this, {
res_model: this.model,
res_id: parseInt(id).toString() === id ? parseInt(id) : id,
context: this.dataset.get_context(),
title: title,
view_id: +this.open_popup_action,
readonly: true,
buttons: [
{text: _t("Edit"), classes: 'btn-primary', close: true, click: function() {
self.dataset.index = self.dataset.get_id_index(id);
self.do_switch_view('form', { mode: "edit" });
}},
{text: _t("Delete"), close: true, click: function() {
self.remove_event(id);
}},
{text: _t("Close"), close: true}
]
}).open();
}
return false;
},
So I think if you remove these lines would be enough:
{text: _t("Delete"), close: true, click: function() {
self.remove_event(id);
}},
By the way, as you can see in the last link, the file to modify (by inheritance) is addons/web_calendar/static/src/js/web_calendar.js

How to use EventListener inside an array with row element

I am using Appcelerator Studio to design a slider menu. Now i need to add EventListener to those slider menu rows. Please tell me how to use EventListener on clicking 'Help' so that i can give some condition within it? My code is below:
var menuTitles = [{title : 'Home'
}, {
title : 'Help'
},{
title: 'Privacy Policy'
}, {
title : 'About Us'
}, {
title : 'Rate This App'
}, {
title : 'Logout'
}];
//Tableview
var tableView = Titanium.UI.createTableView({
data : menuTitles,
allowsSelection:true
});
menuWindow.add(tableView);
console.log(menuTitles[0]);
//console.log(tableView.data);
menuTitles[0].addEventListener('click', function(){ // It seems wrong.
alert("");
some more operation i need to perform inside this actually
});
Add the event listener onto the parent element, in this case the tableView and then select the item you want that using event bubbling, the example code below selects it on the row index e.index but you could easily change this to e.row.title and do a string comparison / add any custom property to the row object and check it with e.row
tableView.addEventListener('click', function (e) {
if (e.index === 1) {
} else if (e.index === 2){
}
etc....
});

How to select a card in a carousel by menu item in a docked menu list in Sencha touch?

I cannot figure out how I can retrieve a given Data item in a store (id-number) to send it to the "setActiveItem" method in a listener:
So I have a store - model:
Ext.regModel('PictureItem', {
fields: ['id', 'titel', 'url']
});
var pictureItems = new Ext.data.Store({
model: 'PictureItem',
data: [
{id:1, titel:'page 1', url:'http://placekitten.com/1024/768'},
{id:2, titel:'page 2', url:'http://placekitten.com/1024/768'},
{id:3, titel:'page 3', url:'http://placekitten.com/1024/768'},
]
});
Here is my menuList called "leftList":
var leftList = new Ext.List({
dock: 'left',
id:'list1',
width: 135,
overlay: true,
itemTpl: '{titel}',
singleSelect: true,
defaults: {
cls: 'pic'
},
store: pictureItems,
listeners:{
selectionchange: function (model, records) {
if (records[0]) {
Ext.getCmp('karte').setActiveItem(!!!Here the number of the selected Item
or respondend "id" in the data store!!!);
}
}
}
});
and the carousel....
var carousel = new Ext.Carousel({
id: 'karte',
defaults: {
cls: 'card'
},
items: [{
scroll: 'vertical',
title: 'Tab 1',
html: '<img class="orientation" alt="" src="img_winkel/titel_v.jpg">'
},
If I call
Ext.getCmp('karte').setActiveItem(2);
it works with the called card - but how can I get the number from the id of the selected item in the menu List /store????
By the way: what does mean:
if (records[0]) {
why [0]?
I FOUND THE ANSWER FOR MYSELF - IT'S EASY:
Ext.getCmp('karte').setActiveItem(records[0].get('id'), {type: 'slide', direction: 'left'});
The secret to get the record-entry is ".get()":
records[0].get('arrayfield')
So now I can change the activeItem in the carousel easely...

Sencha touch - trying to delete row from list

I try to get an editable list with this code:
var isEditing = false;
new Ext.Application({
launch: function(){
new Ext.Panel({
//layout: 'card',
fullscreen: true,
items: new Ext.List({
id: 'myList',
store: new Ext.data.Store({
fields: ['myName'],
data: [{ myName: 1 }, { myName: 2 }, { myName: 3}]
}),
itemSelector: '.x-list-item',
multiSelect: true,
itemTpl: '<span class="name">{myName}</span>',
tpl: new Ext.XTemplate(
'<tpl for=".">' +
'<div class="x-list-item">' +
'<tpl if="this.isEditing()">' +
'<img src="images/delete.gif" ' +
'onclick="Ext.getCmp(\'myList\').myDeleteItem({[xindex-1]})" ' +
'style="vertical-align: middle; margin-right: 15px;"/>' +
'</tpl>' +
'{myName}</div>' +
'</tpl>',
{
compiled: true,
isEditing: function () {
console.log('isEditing (tpl):' + isEditing)
return isEditing;
}
}),
myDeleteItem: function (index) {
var store = this.getStore();
var record = store.getAt(index);
console.log('removing ' + record.data.myName);
store.remove(record);
},
listeners: {
itemtap: function () {
if (isEditing){
console.log('isEditing: ' + isEditing);
return;
}
},
beforeselect: function () {
console.log('isEditing: before ' + !isEditing);
return !isEditing;
}
}
}),
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
layout: { pack: 'right' },
items: [
{
xtype: 'button',
text: 'Edit',
handler: function () {
var list = Ext.getCmp('myList');
if (!isEditing)
list.mySelectedRecords = list.getSelectedRecords();
isEditing = !isEditing;
this.setText(isEditing ? 'Save' : 'Edit');
list.refresh();
if (!isEditing)
list.getSelectionModel().select(list.mySelectedRecords);
}
}]
}]
});
}
});
but its not working like it should. If I press the EDIT button there is no delete-image and so there is no deleted item....
There are 3 things that I can see:
The Template is rendered once, you will need to call .refresh() or .refreshNode() on the list to update any item templates. The better way to accomplish this would be to hide the delete button via CSS and display it when the 'edit' button is clicked.
There is probably a naming conflict between the isEditing variable declared at the top and the isEditing function reference. It is very confusing to have these two things named the same, and can lead to problems with variable scoping.
The click event that you are looking for may be intercepted by the parent list item and Sencha Touch is turning it into a 'itemtap' event on the list item.
I was not able to delete until I added an id field without a datatype to my model. I don't know why as it should know which record to delete via the index.
Ext.regModel('Setting', {
fields: [
{name: 'id'}, // delete works after adding
{name: 'name', type: 'string'}
],
proxy: {
type: 'localstorage',
id: 'settings'
}
Kevin