Skip to content

Instantly share code, notes, and snippets.

@cAstraea
Created April 19, 2016 11:27
Show Gist options
  • Save cAstraea/5362c5d8898bb5e6d28bca8eaa1e7460 to your computer and use it in GitHub Desktop.
Save cAstraea/5362c5d8898bb5e6d28bca8eaa1e7460 to your computer and use it in GitHub Desktop.
muli select deps sugarcrm
({ extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.on("render", this.displayFunction, this);//launch it whenever your page is rendered
this.model.on("change:objectifs_c",this.displayFunction, this);//display changes when the multi select changes for visite objectifs
this.model.on("change:phonobjectif_c",this.displayFunction, this);
this.model.on("change:actioncoobjectif_c",this.displayFunction, this);
},
displayFunction:function(){
if (this.model.get('objectifs_c')) {
Array.prototype.contains = function ( needle ) {
for (i in this) {
if (this[i] == needle) return true;
}
return false;
};
console.log(this.model.get('objectifs_c'));
if (this.model.get('objectifs_c').contains("0") ||this.model.get('objectifs_c').contains("1") || this.model.get('objectifs_c').contains("2") || this.model.get('objectifs_c').contains("3")) {
$('[data-name="v_list_brochure"]').removeClass("vis_action_hidden").effect("highlight", {color: 'CornflowerBlue'}, 500).removeAttr("style");
}else{
// console.log(this.model.get('objectifs_c'));
//console.log(_.indexOf(this.model.get('objectifs_c')));
$('[data-name="v_list_brochure"]').addClass("vis_action_hidden");
}
if(this.model.get('objectifs_c').contains("4") ) { //geste CO sur Dossier
$('[data-name="v_pc_gco_motif"]').removeClass("vis_action_hidden").effect("highlight", {color: 'CornflowerBlue'}, 500).removeAttr("style");
$('[data-name="v_pc_gco_montant"]').removeClass("vis_action_hidden").effect("highlight", {color: 'CornflowerBlue'}, 500).removeAttr("style");
$('[data-name="v_pc_gco_pourcentage"]').removeClass("vis_action_hidden").effect("highlight", {color: 'CornflowerBlue'}, 500).removeAttr("style");
}
else {
$('[data-name="v_pc_gco_motif"]').addClass("vis_action_hidden");
$('[data-name="v_pc_gco_montant"]').addClass("vis_action_hidden");
$('[data-name="v_pc_gco_pourcentage"]').addClass("vis_action_hidden");
}
if(this.model.get('objectifs_c').contains("5") ) { //programation action commerciale
$('[data-name="v_liste_actionco"]').removeClass("vis_action_hidden").effect("highlight", {color: 'CornflowerBlue'}, 500).removeAttr("style");
}
else {
$('[data-name="v_liste_actionco"]').addClass("vis_action_hidden");
}
}
if (this.model.get('phonobjectif_c')) {
console.log(this.model.get('phonobjectif_c'));
}
if (this.model.get('actioncoobjectif_c')) {
console.log(this.model.get('actioncoobjectif_c'));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment