I am trying to make a custom operator group with 5 operators: "City Is", "State Is", "Zip Code Is", "Is Within" (2 inputs, Number Of Miles From and Zip Code), "Is Beyond" (2 inputs, Number Of Miles From and Zip Code).
My issue is with labeling/placeholders for the inputs for each operator. I tried below with no luck:
operators:[
{type: 'City Is', optgroup:'Geo Location', nb_inputs: 1, multiple: false, apply_to: ['string'],placeholder: ['City']},
{type: 'State Is', optgroup:'Geo Location', nb_inputs: 1, multiple: false, apply_to: ['string'],placeholder: ['State']},
{type: 'Zip Code Is', optgroup:'Geo Location', nb_inputs: 1, multiple: false, apply_to: ['string'],placeholder: ['Zip Code']},
{type: 'Is Within', optgroup:'Geo Location', nb_inputs: 2, multiple: false, apply_to: ['string'],placeholder: ['Number of Miles From', 'Zip Code']},
{type: 'Is Beyond', optgroup:'Geo Location', nb_inputs: 2, multiple: false, apply_to: ['string'],placeholder: ['Number of Miles From', 'Zip Code']}
]
Adding placeholders to the filter in an array works, but it is starting from the first element of the array for each operator, which is causing the placeholders to not make sense. ie like below:
filters:[
{
id: 'address',
label: 'Address (geolocation)',
type: 'string',
operators: geo_operators
placeholder: ['City is','State is', 'Zip is','Number of Miles From', 'Zip Code']
}
]
Any help would be much appreciated.
Related
I have a simple_form with a phone number. I'm using Intl-Tel-Input to get the entire phone_number and confirm SMS in different countries (twilio). In console.log, I succeed to display the entire number. When I submit, I just get the phone_number without the country indicator (dial_code)
I read the doc, tried to get it by other way (.value, .data, etc...), but impossible to save the entire phone_number (for example, +33612345678, I just get 61234567).
Here's my code :
<div class="userphonenumber">
<%= f.input :phone_number, label: 'N° de téléphone', required: true, autofocus: true ,
input_html: { autocomplete: "intlNumber" }, wrapper_html: { id: 'userphonenumber' }%>
</div>
<script>
$("#user_phone_number").intlTelInput({
formatOnInit: true,
separateDialCode: true,
onlyCountries: ['fr', 'at', 'be', 'bg', 'cz', 'dk', 'de', 'ee', 'ie', 'el', 'es', 'hr', 'it', 'cy', 'lv', 'lt', 'lu', 'hu', 'mt', 'nl', 'pl', 'pt', 'ro', 'si', 'sk', 'fi', 'se', 'uk'],
initialCountry: "fr"
});
const flag = document.querySelector(".flag-container")
flag.addEventListener("click", () => {
var intlNumber = $("#user_phone_number").intlTelInput("getNumber");
console.log("intlNumber", intlNumber)
var input = document.querySelector("#user_phone_number");
window.intlTelInput(input);
});
</script>
I'm expecting to get +33612345678 to use the phone_number with twilio. Beginner on RoR and JS. Did I miss something ?
Thanks for your help.
Finally fix with this solution :
<script>
$("#user_phone_number").intlTelInput({
formatOnInit: true,
separateDialCode: true,
onlyCountries: ['at', 'be', 'bg', 'cz', 'dk', 'de', 'ee', 'ie', 'el', 'es', 'fr', 'hr', 'it', 'cy', 'lv', 'lt', 'lu', 'hu', 'mt', 'nl', 'pl', 'pt', 'ro', 'si', 'sk', 'fi', 'se', 'uk'],
initialCountry: "fr",
});
var phone = document.getElementById('user_phone_number')
phone.addEventListener('keyup', (event) => {
console.log(event)
});
$("form").submit(function() {
$('#user_phone_number').val($(phone).intlTelInput("getNumber"));
});
</script>
$(".form").submit( function(eventObj) {
$("<input />").attr("type", "hidden")
.attr("name", "ccode")
.attr("value", $(this).find(".selected-dial-code").text())
.appendTo(".form");
return true;
});
I have jqxgrid.I am very new to jqxgrid.I want to display total of recordes or values in column.
Can any tell me how to do
enter image description here
jqxgrid have feature to show aggregates for some column, that aggregates could be 'SUM', 'COUNT', or 'AVERAGE'
you can set the aggregates types when u set the column setting in jqxgrid declaration.
for simple example is like this :
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 850,
source: dataAdapter,
showstatusbar: true,
statusbarheight: 50,
showaggregates: true,
columns: [
{ text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 170 },
{ text: 'Last Name', datafield: 'lastname', columntype: 'textbox', width: 170 },
{ text: 'Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum', 'avg'] }
]
});
for custom aggregates, u can learn from this link
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/aggregates.htm?arctic
for complete documentation for aggregates please check the API's documentation from their documentation.
hope this helps
i have a array of hashes like this
data = [{code: 'a', expire1: '10', stock1; '10', expire2: '11', stock2; '15'}, {code: 'b', expire1: '10', stock1; '10', expire2: '11', stock2; '15', expire3: '12', stock3; '25'}, {code: 'c', expire1: '10', stock1; '10'}]
i want to select the data with the longest/biggest count of every hash inside, so the output is must like this
{code: 'b', expire1: '10', stock1; '10', expire2: '11', stock2; '15', expire3: '12', stock3; '25'}
how can i do that ??
use Enumerable#max_by
>> data.max_by(&:length)
=> {:code=>"b", :expire1=>"10", :stock1=>"10", :expire2=>"11", :stock2=>"15", :expire3=>"12", :stock3=>"25"}
I would like some help in order to prepare my data gathered from the database for charting.
I have a Browser model where I store all the data.
From each model I want to select the name attribute, I will put a color according an integer attribute in the model (for example if integer is 1, color => "#4572A7") and the y attribute from the model.
Can someone provide an example of the most efficient way to achieve this data format?
Final format of the data:
[
{
:name=> 'Firefox',
:y=> 1,
:color => "#4572A7"
},
{
:name=> 'IE',
:y=> 1,
:color => "#AA4643"
},
{
:name=> 'Chrome',
:y=> 1,
:color => "#89A54E"
},
{
:name=> 'Safari',
:y=> 1,
:color => "#80699B"
},
{
:name=> 'Opera',
:y=> 1,
:color => "#3D96AE"
},
{
:name=> 'Others',
:y=> 1,
:color => "#DB843D"
}
]
You could have a method that does the number-to-color translation and have something like
#browsers.to_json(methods: [:the_method_that_translates_numbers_to_colors], only: [:name, :y])
Hope that helps,
NHI
Symfony 1.4
Propel (with sfPropel15Plugin)
I have a multilanguage Gallery with the following schema:
# Galleries
pi_gallery:
_attributes:
phpName: Gallery
isI18N: true
i18nTable: pi_gallery_i18n
_propel_behaviors:
sortable: ~
id: ~
active:
type: boolean
default: true
required: true
created_at: ~
updated_at: ~
pi_gallery_i18n:
_attributes:
phpName: GalleryI18n
id:
type: integer
foreignTable: pi_gallery
foreignReference: id
required: true
primaryKey: true
onDelete: cascade
culture:
isCulture: true
type: varchar
size: 7
required: true
primaryKey: true
name:
type: varchar
size: 255
required: false
description:
type: longvarchar
required: false
# Images
pi_gallery_image:
_attributes:
phpName: GalleryImage
isI18N: true
i18nTable: pi_gallery_image_i18n
id: ~
gallery_id:
type: integer
foreignTable: pi_gallery
foreignReference: id
required: true
image:
type: varchar
size: 255
required: true
created_at: ~
updated_at: ~
pi_gallery_image_i18n:
_attributes:
phpName: GalleryImageI18n
id:
type: integer
foreignTable: pi_gallery_image
foreignReference: id
required: true
primaryKey: true
onDelete: cascade
culture:
isCulture: true
type: varchar
size: 7
required: true
primaryKey: true
description:
type: varchar
size: 255
required: false
I'm trying to embed the Image forms in the Gallery using the following:
# GalleryForm.class
public function configure()
{
unset(
$this['alias'],
$this['created_at'],
$this['updated_at']
);
$this->widgetSchema['article_id']->setOption('renderer_class', 'sfWidgetFormPropelJQueryAutocompleter');
$this->widgetSchema['article_id']->setOption('renderer_options', array(
'model' => 'Article',
'url' => '/article/ajax'
));
$this->validatorSchema['article_id'] = new sfValidatorPass();
$this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));
$this->widgetSchema->setLabel('en','English');
$this->widgetSchema->setLabel('es','Español');
$this->widgetSchema->setLabel('de','Deutsch');
$this->widgetSchema->setLabel('it','Italiano');
$this->widgetSchema->setLabel('fr','Francais');
$this->embedRelation('GalleryImage'); // Embeds the Relation between the GalleryImage model and the Gallery Model
}
# GalleryImageForm.class:
public function configure()
{
unset(
$this['created_at'],
$this['updated_at'],
$this['gallery_id'],
$this['sortable_rank']
);
if ($this->isNew()) unset($this['id']);
$this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));
$image = $this->getObject()->getImage();
$template = (!is_null($image) || $image != "") ? '<div>%file%<br />%input%<br />%delete% %delete_label%</div>' : '';
$this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array(
'label' => 'Imagen',
'file_src' => '/'.sfConfig::get('sf_upload_dir_name').'/images/galleries/thumbs/'.substr($this->getObject()->getImage(),0,-4) . '.jpg',
'is_image' => true,
'edit_mode' => !$this->isNew() && $image != "",
'with_delete' => true,
'delete_label'=>'Eliminar archivo existente',
'template' => $template
));
$this->validatorSchema['image_delete'] = new sfValidatorPass();
$this->validatorSchema['image'] = new sfValidatorFile(array(
'path' => sfConfig::get('sf_upload_dir').'/images/galleries',
'required' => false,
'mime_types' => 'web_images'
));
}
This appears to embed the forms as expected ... initially. The GalleryForm appears with Multilanguage Descriptions and the ImageForms embed beneath them. So far so good.
Saving the form however shows that all is not good.
Two records are saved initially, one with just the image and the other with just the i18n fields. The i18n fields also have the id of the second record added so there is no way of relating the image to the i18n fields. Maybe the order of saving the forms is wrong?
Has anyone successfully got a form to work that embeds I18n in an embedded Relation? Or does anyone have any idea of a workaround? I've read about something about overriding saveEmbeddedForms but I don't even know where to start with that.
Any help appreciated.
Fixed in the sfPropelORMPlugin:
https://github.com/propelorm/sfPropelORMPlugin/issues/13
https://github.com/propelorm/sfPropelORMPlugin/pull/76
https://github.com/propelorm/sfPropelORMPlugin/issues/38