main.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {"label":"JS","syntax":"js"}
  2. //CHARGEMENT DE LA PAGE
  3. function init_plugin_{{plugin}}(){
  4. switch($.urlParam('page')){
  5. default:
  6. break;
  7. }
  8. {{#advanced-search}}$('#{{entity-readable}}s').sortable_table({
  9. onSort : {{plugin_entity_deduplicate}}_search
  10. });{{/advanced-search}}{{^advanced-search}}{{plugin_entity_deduplicate}}_search();{{/advanced-search}}
  11. }
  12. {{#setting}}//Enregistrement des configurations
  13. function {{plugin}}_setting_save(){
  14. $.action({
  15. action: '{{plugin}}_setting_save',
  16. fields: $('#{{plugin}}-setting-form').toJson()
  17. },function(){
  18. $.message('success','Enregistré');
  19. });
  20. }{{/setting}}
  21. /** {{ENTITYLABEL}} **/
  22. //Récuperation d'une liste {{entityLabel}} dans le tableau #{{entity}}s
  23. function {{plugin_entity_deduplicate}}_search(callback{{#search-export}},exportMode{{/search-export}}){{{#advanced-search}}
  24. var box = new FilterBox('#{{plugin_entity_deduplicate}}-filters');
  25. if(exportMode) $('.btn-export').addClass('btn-preloader');{{/advanced-search}}
  26. $('#{{entity-readable}}s').fill({
  27. action:'{{plugin_entity_deduplicate}}_search'{{#advanced-search}},
  28. filters: box.filters(),
  29. sort: $('#{{entity-readable}}s').sortable_table('get'){{/advanced-search}}{{#search-export}},
  30. export: !exportMode ? false : exportMode{{/search-export}}
  31. },function(response){
  32. {{#advanced-search}}if(!exportMode) $('.results-count > span').text(response.pagination.total);
  33. {{/advanced-search}}if(callback!=null) callback();
  34. });
  35. }
  36. //Ajout ou modification {{entityLabel}}
  37. function {{plugin_entity_deduplicate}}_save(){
  38. var data = $('#{{entity-readable}}-form').toJson();
  39. $.action(data,function(r){{{#edit-form}}
  40. $('#{{entity-readable}}-form').attr('data-id','');
  41. {{plugin_entity_deduplicate}}_search();{{/edit-form}}
  42. $('#{{entity-readable}}-form').attr('data-id',r.id);
  43. $.urlParam('id',r.id);
  44. $.message('success','Enregistré');
  45. });
  46. }
  47. {{#edit-form}}//Récuperation ou edition {{entityLabel}}
  48. function {{plugin_entity_deduplicate}}_edit(element){
  49. var line = $(element).closest('.item-line');
  50. $.action({
  51. action: '{{plugin_entity_deduplicate}}_edit',
  52. id: line.attr('data-id')
  53. },function(r){
  54. $('#{{entity-readable}}-form').fromJson(r);
  55. init_components('#{{entity-readable}}-form');
  56. $('#{{entity-readable}}-form').attr('data-id',r.id);
  57. });
  58. }
  59. {{/edit-form}}
  60. //Suppression {{entityLabel}}
  61. function {{plugin_entity_deduplicate}}_delete(element){
  62. if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
  63. var line = $(element).closest('.item-line');
  64. $.action({
  65. action: '{{plugin_entity_deduplicate}}_delete',
  66. id: line.attr('data-id')
  67. },function(r){
  68. line.remove();
  69. $.message('info','Item supprimé');
  70. });
  71. }