projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1178 from ravishnair/civihr
[civicrm-core.git]
/
js
/
jquery
/
jquery.crmeditable.js
diff --git
a/js/jquery/jquery.crmeditable.js
b/js/jquery/jquery.crmeditable.js
index af3ba7549147ed457e19c43a05b2421c895eaf44..cd7c9f02ac9143edfc5ee7229745a378833e95c6 100644
(file)
--- a/
js/jquery/jquery.crmeditable.js
+++ b/
js/jquery/jquery.crmeditable.js
@@
-27,7
+27,7
@@
*
*
* This offers two features:
*
*
* This offers two features:
-* - crmEditable() edit in place of a single field
+* - crmEditable() edit in place of a single field
* (mostly a wrapper that binds jeditable features with the ajax api and replies on crm-entity crmf-{field} html conventions)
* if you want to add an edit in place on a template:
* - add a class crm-entity and id {EntityName}-{Entityid} higher in the dom
* (mostly a wrapper that binds jeditable features with the ajax api and replies on crm-entity crmf-{field} html conventions)
* if you want to add an edit in place on a template:
* - add a class crm-entity and id {EntityName}-{Entityid} higher in the dom
@@
-72,8
+72,8
@@
// param in : a dom object that contains the field name as a class crmf-xxx
var getFieldName = function (field) {
if ($(field).data('field')) {
// param in : a dom object that contains the field name as a class crmf-xxx
var getFieldName = function (field) {
if ($(field).data('field')) {
- return $(field).data('field');
- }
+ return $(field).data('field');
+ }
var fieldName=field.className.match(/crmf-(\S*)/)[1];
if (!fieldName) {
console && console.log && console.log("Couldn't get the crm-editable field name to modify. You need to set crmf-{field_name} or data-{field_name}");
var fieldName=field.className.match(/crmf-(\S*)/)[1];
if (!fieldName) {
console && console.log && console.log("Couldn't get the crm-editable field name to modify. You need to set crmf-{field_name} or data-{field_name}");
@@
-82,7
+82,6
@@
return fieldName;
}
return fieldName;
}
-
var checkable = function () {
$(this).change (function() {
var params={sequential:1};
var checkable = function () {
$(this).change (function() {
var params={sequential:1};
@@
-91,7
+90,7
@@
if (!getEntityID (this,function (e,id) {
entity=e;
params.id = id;
if (!getEntityID (this,function (e,id) {
entity=e;
params.id = id;
-
+
})) { return };
params['field']=getFieldName(this);
})) { return };
params['field']=getFieldName(this);
@@
-99,13
+98,13
@@
return false;
params['value']=checked?'1':'0';//seems that the ajax backend gets lost with boolean
return false;
params['value']=checked?'1':'0';//seems that the ajax backend gets lost with boolean
- //CRM.api.call(this,entity,'create',params,{ create is still too buggy & perf
- CRM.api.call(this,entity,'setvalue',params,{
+ CRM.api(entity,'setvalue',params,{
+ context: this,
error: function (data) {
error: function (data) {
- editableSettings.error.call(this,entity,
fieldName
,checked,data);
+ editableSettings.error.call(this,entity,
params.field
,checked,data);
},
success: function (data) {
},
success: function (data) {
- editableSettings.success.call(this,entity,
fieldName
,checked,data);
+ editableSettings.success.call(this,entity,
params.field
,checked,data);
}
});
});
}
});
});
@@
-142,7
+141,7
@@
return;
}
return;
}
- if (this.nodeName = 'A') {
+ if (this.nodeName =
=
'A') {
if (this.className.indexOf('crmf-') == -1) { // it isn't a jeditable field
var formSettings= $.extend({}, editableSettings.form ,
{source: $i.attr('href')
if (this.className.indexOf('crmf-') == -1) { // it isn't a jeditable field
var formSettings= $.extend({}, editableSettings.form ,
{source: $i.attr('href')
@@
-157,17
+156,17
@@
var id= $i.closest('.crm-entity').attr('id');
if (id) {
var e=id.match(/(\S*)-(\S*)/);
var id= $i.closest('.crm-entity').attr('id');
if (id) {
var e=id.match(/(\S*)-(\S*)/);
- if (!e)
+ if (!e)
console && console.log && console.log("Couldn't get the entity id. You need to set class='crm-entity' id='{entityName}-{id}'");
formSettings.entity=e[1];
formSettings.id=e[2];
console && console.log && console.log("Couldn't get the entity id. You need to set class='crm-entity' id='{entityName}-{id}'");
formSettings.entity=e[1];
formSettings.id=e[2];
- }
+ }
if ($i.hasClass('crm-dialog')) {
$i.click (function () {
var $n=$('<div>Loading</div>').appendTo('body');
$n.dialog ({modal:true,width:500});
$n.crmForm (formSettings);
if ($i.hasClass('crm-dialog')) {
$i.click (function () {
var $n=$('<div>Loading</div>').appendTo('body');
$n.dialog ({modal:true,width:500});
$n.crmForm (formSettings);
- return false;
+ return false;
});
} else {
$i.click (function () {
});
} else {
$i.click (function () {
@@
-179,7
+178,7
@@
return false;
};
$n.crmForm (formSettings);
return false;
};
$n.crmForm (formSettings);
- return false;
+ return false;
});
}
return;
});
}
return;
@@
-243,12
+242,17
@@
}
if ($i.data('action')) {
}
if ($i.data('action')) {
- params[params['field']]=value;//format for create at least
+ var fieldName = params['field'];
+ delete params['field'];
+ delete params['value'];
+
+ params[fieldName]=value;//format for create at least
action=$i.data('action');
} else {
action="setvalue";
}
action=$i.data('action');
} else {
action="setvalue";
}
- CRM.api.call(this,entity,action,params,{
+ CRM.api(entity, action, params, {
+ context: this,
error: function (data) {
editableSettings.error.call(this,entity,fieldName,value,data);
},
error: function (data) {
editableSettings.error.call(this,entity,fieldName,value,data);
},
@@
-293,7
+297,7
@@
$this.html("<div class='crm-editable-saving'>Saving...</div>");
return true;
},
$this.html("<div class='crm-editable-saving'>Saving...</div>");
return true;
},
- success:function(response) {
+ success:function(response) {
if (response.indexOf('crm-error') >= 0) { // we got an error, re-display the page
$this.html(response);
formLoaded(target);
if (response.indexOf('crm-error') >= 0) { // we got an error, re-display the page
$this.html(response);
formLoaded(target);
@@
-304,7
+308,7
@@
settings.success(response);
}
}
settings.success(response);
}
}
- }).append('<input type="hidden" name="snippet" value="1"/>'+destination).trigger('load');
+ }).append('<input type="hidden" name="snippet" value="1"/>'+destination).trigger('load');
settings.load(target);
};
settings.load(target);
};