djgentelella 0.3.24__py3-none-any.whl → 0.3.26__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. djgentelella/__init__.py +1 -1
  2. djgentelella/locale/es/LC_MESSAGES/django.mo +0 -0
  3. djgentelella/locale/es/LC_MESSAGES/django.po +14 -2
  4. djgentelella/management/commands/createbasejs.py +3 -1
  5. djgentelella/management/commands/loaddevstatic.py +9 -0
  6. djgentelella/objectmanagement.py +2 -2
  7. djgentelella/serializers/paginators.py +15 -0
  8. djgentelella/static/djgentelella.vendors.min.css +19 -0
  9. djgentelella/static/djgentelella.vendors.min.js +6 -0
  10. djgentelella/static/gentelella/js/base/api_list.js +135 -0
  11. djgentelella/static/gentelella/js/base/form.common.js +255 -0
  12. djgentelella/static/gentelella/js/base/formset.js +102 -83
  13. djgentelella/static/gentelella/js/base.js +494 -81
  14. djgentelella/static/gentelella/js/obj_api_management.js +5 -147
  15. djgentelella/static/gentelella/js/widgets.js +3 -0
  16. djgentelella/static/vendors/htmlx/htmx.min.js +1 -0
  17. djgentelella/static/vendors/pdfjs/interact.min.js +4 -0
  18. djgentelella/static/vendors/pdfjs/pdf.min.mjs +21 -0
  19. djgentelella/static/vendors/pdfjs/pdf.worker.min.mjs +21 -0
  20. djgentelella/static/vendors/pdfjs/pdf_viewer.min.css +19 -0
  21. djgentelella/templates/gentelella/base.html +1 -1
  22. djgentelella/templates/gentelella/blocks/listcard_template.html +60 -0
  23. djgentelella/templates/gentelella/blocks/squirrelly_pagination.html +34 -0
  24. djgentelella/templates/gentelella/plain.html +1 -1
  25. djgentelella/templates/gentelella/statics/javascript.html +4 -0
  26. djgentelella/templates/gentelella/statics/stylesheets.html +1 -2
  27. djgentelella/views/listAreaViewset.py +74 -0
  28. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/METADATA +9 -2
  29. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/RECORD +33 -22
  30. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/AUTHORS +0 -0
  31. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/LICENSE.txt +0 -0
  32. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/WHEEL +0 -0
  33. {djgentelella-0.3.24.dist-info → djgentelella-0.3.26.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,135 @@
1
+ class CardList {
2
+ constructor(containerId, apiUrl, actions={}) {
3
+ this.container = document.getElementById(containerId);
4
+ this.apiUrl = apiUrl;
5
+ this.page = 1;
6
+ this.data=null;
7
+ this.page_size = 10;
8
+ this.totalPages = 1;
9
+ this.recordsTotal = 0;
10
+ this.template = '';
11
+ this.filters = {};
12
+ this.actions=actions;
13
+ this.fetchData();
14
+
15
+ }
16
+
17
+ async fetchData() {
18
+ try {
19
+ const queryParams = new URLSearchParams({
20
+ page: this.page,
21
+ page_size: this.page_size,
22
+ ...(this.filters || {}),
23
+ }).toString();
24
+
25
+ const url = `${this.apiUrl}?${queryParams}`;
26
+ const response = await fetch(url);
27
+ if (!response.ok) throw new Error(`Error HTTP: ${response.status}`);
28
+
29
+ const data = await response.json();
30
+ this.template = data.template || this.template;
31
+ this.totalPages = data.totalPages || 1;
32
+ this.recordsTotal = data.recordsTotal || 0;
33
+ this.process_data(data);
34
+ this.render(data);
35
+ } catch (error) {
36
+ console.error('Error fetching data:', error);
37
+ }
38
+ }
39
+
40
+ process_data(data){
41
+ this.data={};
42
+ data.data.forEach(item => {
43
+ this.data[item.id]=item;
44
+ })
45
+ }
46
+
47
+ render(data) {
48
+ if (!this.template) {
49
+ console.error("No template found!");
50
+ return;
51
+ }
52
+ this.container.innerHTML = Sqrl.render(this.template, data, Sqrl.getConfig({ tags: ["<%", "%>"] }));
53
+ gt_find_initialize_from_dom(this.container);
54
+ this.doPagination();
55
+ this.dofiltering();
56
+ this.doPageSizeOptions();
57
+ this.doObjActions()
58
+ }
59
+
60
+ async getFilters(){
61
+ const form = this.container.querySelectorAll('.filter_form');
62
+
63
+ const result = await convertToStringJson(form);
64
+ this.filters = JSON.parse(result);
65
+ this.fetchData();
66
+ }
67
+ dofiltering(){
68
+ /**
69
+ const forminput = this.container.querySelectorAll('.filter_form input, .filter_form select');
70
+ const parent=this;
71
+ forminput.forEach(input => {
72
+ input.onchange=function(event){
73
+ parent.getFilters();
74
+ }
75
+ });
76
+ **/
77
+ }
78
+ doPageSizeOptions(){
79
+ const formselect = this.container.querySelectorAll('.page_size_select');
80
+ const parent=this;
81
+ parent.page_size=parseInt(formselect[0].value);
82
+ formselect.forEach(input => {
83
+ input.onchange=function(event){
84
+ parent.page_size=event.target.value
85
+ parent.getFilters();
86
+ }
87
+ });
88
+
89
+ }
90
+ doPagination(){
91
+ const alink = this.container.querySelectorAll('.pagination a');
92
+ const parent=this;
93
+ alink.forEach(link => {
94
+ link.onclick = function(event) {
95
+ parent.page=event.target.dataset.page;
96
+ parent.fetchData();
97
+ }
98
+ });
99
+ }
100
+ doObjActions(){
101
+ const actions = this.container.querySelectorAll('.obj_action');
102
+ const parent=this;
103
+ actions.forEach(action => {
104
+ action.onclick = function(event) {
105
+ event.preventDefault();
106
+ var pk = action.dataset.instance;
107
+ var name = action.dataset.action;
108
+ if (typeof parent.actions[name] === 'function') {
109
+ parent.actions[name](pk, parent.data[pk]);
110
+ }
111
+ }
112
+ })
113
+ const generalactions = this.container.querySelectorAll('.general_action');
114
+ generalactions.forEach(action => {
115
+ action.onclick = function(event) {
116
+ event.preventDefault();
117
+ var name = action.dataset.action;
118
+ if (typeof parent.actions[name] === 'function') {
119
+ parent.actions[name]();
120
+ }else{
121
+ if (typeof parent[name] === 'function') parent[name]();
122
+ }
123
+ }
124
+ })
125
+ }
126
+ search(){
127
+ this.getFilters();
128
+ }
129
+ clean(){
130
+ const form = this.container.querySelectorAll('.filter_form');
131
+ clear_action_form(form);
132
+ this.container.querySelectorAll('.filter_form input').forEach(i=>{i.value="";});
133
+ this.getFilters();
134
+ }
135
+ }
@@ -0,0 +1,255 @@
1
+ function convertFileToBase64(file) {
2
+ return new Promise((resolve, reject) => {
3
+ const reader = new FileReader();
4
+
5
+ reader.onload = () => {
6
+ const base64String = reader.result.split(',')[1];
7
+ resolve(base64String);
8
+ };
9
+
10
+ reader.onerror = (error) => {
11
+ reject(error);
12
+ };
13
+
14
+ reader.readAsDataURL(file);
15
+ });
16
+ }
17
+
18
+ async function obtainFormAsJSON(form, prefix = '', extras = {}, format = true) {
19
+ const fields = form.elements;
20
+ const formData = {};
21
+ // typeof variable === 'function'
22
+ for (let key in extras) {
23
+ if (typeof extras[key] === 'function') {
24
+ formData[key] = extras[key](form, key, prefix);
25
+ } else {
26
+ formData[key] = extras[key];
27
+ }
28
+ }
29
+
30
+ for (let i = 0; i < fields.length; i++) {
31
+ const field = fields[i];
32
+
33
+ if (field.type !== 'submit' && field.type !== 'button') {
34
+ const fieldName = field.name.replace(prefix, '');
35
+ if (field.type === 'textarea') {
36
+ formData[fieldName] = $(field).val();
37
+ } else if (field.type === 'checkbox') {
38
+ formData[fieldName] = field.checked;
39
+ } else if (field.type === 'radio') {
40
+ if (field.checked) {
41
+ formData[fieldName] = $(field).val();
42
+ }
43
+ } else if (field.type === 'file') {
44
+ const files = Array.from(field.files);
45
+ const filesBase64 = [];
46
+
47
+ for (let j = 0; j < files.length; j++) {
48
+ const file = files[j];
49
+ try {
50
+ const base64String = await convertFileToBase64(file);
51
+ filesBase64.push({name: file.name, value: base64String});
52
+ } catch (error) {
53
+ console.error('Error converting file:', error);
54
+ }
55
+ }
56
+
57
+ formData[fieldName] = filesBase64;
58
+ } else if (field.multiple) {
59
+ const selectedOptions = Array.from(field.selectedOptions);
60
+ const selectedValues = selectedOptions.map((option) => option.value);
61
+ formData[fieldName] = selectedValues;
62
+ } else {
63
+ formData[fieldName] = field.value;
64
+ }
65
+ }
66
+ }
67
+
68
+ if (format) {
69
+ return JSON.stringify(formData);
70
+ }
71
+
72
+ return formData;
73
+ }
74
+
75
+ function convertToStringJson(form, prefix = "", extras = {}, format = true) {
76
+ return obtainFormAsJSON(form[0], prefix, extras, format);
77
+ }
78
+
79
+ function load_errors(error_list, obj, parentdiv) {
80
+ ul_obj = "<ul class='errorlist form_errors d-flex justify-content-center'>";
81
+ error_list.forEach((item) => {
82
+ ul_obj += "<li>" + item + "</li>";
83
+ });
84
+ ul_obj += "</ul>"
85
+ $(obj).parents(parentdiv).prepend(ul_obj);
86
+ return ul_obj;
87
+ }
88
+
89
+ function form_field_errors(target_form, form_errors, prefix, parentdiv) {
90
+ var item = "";
91
+ for (const [key, value] of Object.entries(form_errors)) {
92
+ item = " #id_" + prefix + key;
93
+ if (target_form.find(item).length > 0) {
94
+ load_errors(form_errors[key], item, parentdiv);
95
+ }
96
+ }
97
+ }
98
+
99
+ function response_manage_type_data(instance, err_json_fn, error_text_fn) {
100
+ return function (response) {
101
+ const contentType = response.headers.get("content-type");
102
+ if (response.ok) {
103
+ if (contentType && contentType.indexOf("application/json") !== -1) {
104
+ return response.json();
105
+ } else {
106
+ return response.text();
107
+ }
108
+ } else {
109
+ if (contentType && contentType.indexOf("application/json") !== -1) {
110
+ response.json().then(data => err_json_fn(instance, data));
111
+ } else {
112
+ response.text().then(data => error_text_fn(instance, data));
113
+ }
114
+ return Promise.resolve(false);
115
+ }
116
+
117
+ return Promise.reject(response); // then it will go to the catch if it is an error code
118
+ }
119
+ }
120
+
121
+ function clear_action_form(form) {
122
+ // clear switchery before the form reset so the check status doesn't get changed before the validation
123
+ $(form).find("input[data-switchery=true]").each(function () {
124
+ if ($(this).prop("checked")) { // only reset it if it is checked
125
+ $(this).trigger("click").prop("checked", false);
126
+ }
127
+ });
128
+ $(form).find('[data-widget="TaggingInput"],[data-widget="EmailTaggingInput"]').each(function (i, e) {
129
+ var tg = $(e).data().tagify;
130
+ tg.removeAllTags();
131
+ });
132
+ $(form).find('[data-widget="FileChunkedUpload"],[data-widget="FileInput"]').each(function (i, e) {
133
+ var tg = $(e).data().fileUploadWidget;
134
+ tg.resetEmpty();
135
+ });
136
+ $(form).trigger('reset');
137
+ $(form).find("select option:selected").prop("selected", false);
138
+ $(form).find("select").val(null).trigger('change');
139
+ $(form).find("ul.form_errors").remove();
140
+ $(form).find(".file-link").remove();
141
+ }
142
+
143
+ var gt_form_modals = {}
144
+ var gt_detail_modals = {}
145
+ var gt_crud_objs = {};
146
+
147
+ function updateInstanceValuesForm(form, name, value) {
148
+ var item = form.find(
149
+ 'input[name="' + name + '"], ' +
150
+ 'textarea[name="' + name + '"], ' +
151
+ 'select[name="' + name + '"]'
152
+ );
153
+ item.each(function (i, inputfield) {
154
+ let done = false;
155
+ inputfield = $(inputfield);
156
+
157
+ if (inputfield.attr('class') === "chunkedvalue") {
158
+ if (value) {
159
+ var chunked = form.find('input[name="' + name + '_widget"]').data('fileUploadWidget');
160
+ chunked.addRemote(value);
161
+ }
162
+ done = true;
163
+ } else if (inputfield.attr('type') === 'file') {
164
+ if (value) {
165
+ var newlink = document.createElement('a');
166
+ newlink.href = value.url;
167
+ newlink.textContent = value.name;
168
+ newlink.target = "_blank";
169
+ newlink.classList.add("link-primary");
170
+ newlink.classList.add("file-link");
171
+ newlink.classList.add("d-block");
172
+ inputfield.before(newlink)
173
+ }
174
+ done = true;
175
+ } else if (inputfield.attr('type') === "checkbox") {
176
+ if (inputfield.data().widget === "YesNoInput") {
177
+ inputfield.prop("checked", !value);
178
+ inputfield.trigger("click");
179
+ done = true;
180
+ } else {
181
+ inputfield.prop("checked", value);
182
+ }
183
+ done = true;
184
+ } else if (inputfield.attr('type') === "radio") {
185
+ var is_icheck = inputfield.closest('.gtradio').length > 0;
186
+ var sel = inputfield.filter(function () {
187
+ return this.value === value.toString()
188
+ });
189
+ if (sel.length > 0) {
190
+ sel.prop("checked", true);
191
+ if (is_icheck) {
192
+ sel.iCheck('update');
193
+ sel.iCheck('check');
194
+ }
195
+
196
+ } else {
197
+ inputfield.prop("checked", false);
198
+ if (is_icheck) {
199
+ inputfield.iCheck('update');
200
+ inputfield.iCheck('uncheck');
201
+ }
202
+ }
203
+ done = true;
204
+ }
205
+ if (inputfield.data().widget === "EditorTinymce" || inputfield.data().widget === "TextareaWysiwyg") {
206
+ tinymce.get(inputfield.attr('id')).setContent(value);
207
+ done = true;
208
+ }
209
+ if (inputfield.data().widget === "TaggingInput" || inputfield.data().widget === "EmailTaggingInput") {
210
+ var tagifyelement = inputfield.data().tagify;
211
+ tagifyelement.removeAllTags();
212
+ tagifyelement.loadOriginalValues(value);
213
+ done = true;
214
+ }
215
+
216
+ // New code for testing (*** start ***)
217
+ // data loading in select, autocompleteselect, autocompletemultiselect
218
+ else if (inputfield.is('select') && inputfield.data().widget === "Select") {
219
+ inputfield.val(value).trigger('change');
220
+ done = true;
221
+ } else if (inputfield.is('select') && inputfield.data().widget === "AutocompleteSelect") {
222
+ let data = value;
223
+ let select2Obj = inputfield.data('select2');
224
+ if (select2Obj) {
225
+ inputfield.select2('trigger', 'select', {
226
+ data: data
227
+ });
228
+ }
229
+ done = true;
230
+ } else if (inputfield.is('select') && inputfield.data().widget === "AutocompleteSelectMultiple") {
231
+
232
+ if (Array.isArray(value)) {
233
+ value.forEach(item => {
234
+ let newOption = new Option(item.text, item.id, true, true);
235
+ inputfield.append(newOption);
236
+ });
237
+ inputfield.trigger('change');
238
+ }
239
+ done = true;
240
+ }
241
+ // New code for testing (*** end ***)
242
+
243
+ if (!done) {
244
+ inputfield.val(value);
245
+ }
246
+ });
247
+ }
248
+
249
+ function updateInstanceForm(form, data) {
250
+ for (let key in data) {
251
+ if (data.hasOwnProperty(key)) {
252
+ updateInstanceValuesForm(form, key, data[key])
253
+ }
254
+ }
255
+ }
@@ -1,21 +1,23 @@
1
- function gtforms(index,manager, formList, extra=true) {
1
+ function gtforms(index, manager, formList, extra = true) {
2
2
  return {
3
3
  index: index,
4
4
  order: index,
5
+ deleted: false,
5
6
  manager: manager,
6
7
  formList: formList,
7
8
  extra: extra,
8
9
  instance: null,
9
- deleteForm: function(){
10
- if( !this.manager.validateDeleteForm()) {
11
- this.manager.notify('error', 'You can not delete this form, minimum form validation failed' )
12
- return;
13
- }
10
+ deleteForm: function () {
11
+ if (!this.manager.validateDeleteForm()) {
12
+ this.manager.notify('error', 'You can not delete this form, minimum form validation failed')
13
+ return;
14
+ }
15
+ this.deleted = true;
14
16
  this.instance.hide();
15
- this.instance.find('input[name="'+this.manager.prefix+'-'+this.index+'-DELETE"]').prop( "checked", true );
17
+ this.instance.find('input[name="' + this.manager.prefix + '-' + this.index + '-DELETE"]').prop("checked", true);
16
18
  this.manager.deleteForm(this.order);
17
19
  },
18
- render: function(){
20
+ render: function () {
19
21
  var html = this.manager.template.replace(/__prefix__/gi, this.index);
20
22
  this.instance = $(html);
21
23
  formList.append(this.instance);
@@ -23,37 +25,42 @@ function gtforms(index,manager, formList, extra=true) {
23
25
  this.registerBtns();
24
26
 
25
27
  },
26
- reorder: function(oper){
27
- var brother = this.manager.getForm(this.order+oper);
28
- this.manager.switchFrom(this.order, this.order+oper);
29
- if(brother != null){
30
- if(oper == 1 ){
28
+ reorder: function (oper) {
29
+ var brother = this.manager.getForm(this.order + oper);
30
+ this.manager.switchFrom(this.order, this.order + oper);
31
+ if (brother != null) {
32
+ if (oper == 1) {
31
33
  this.instance.before(brother.instance);
32
- }else{
34
+ } else {
33
35
  brother.instance.before(this.instance);
34
36
  }
35
37
  }
36
38
  },
37
- registerBtns: function(){
39
+ registerBtns: function () {
38
40
  this.instance.find('.deletebtn').on('click', this.callDelete(this));
39
41
  // down increment order and up decrement order when forms are inserted in bottom
40
42
  this.instance.find('.btndown').on('click', this.callReorder(this, 1));
41
43
  this.instance.find('.btnup').on('click', this.callReorder(this, -1));
42
44
  },
43
- callDelete: function(instance){
44
- return () => { instance.deleteForm() };
45
+ callDelete: function (instance) {
46
+ return () => {
47
+ instance.deleteForm()
48
+ };
45
49
  },
46
- initializeWidgets: function(instance){
50
+ initializeWidgets: function (instance) {
47
51
  gt_find_initialize(instance);
48
52
  },
49
- callReorder: function(instance, oper){
50
- return () => { instance.reorder(oper) }
53
+ callReorder: function (instance, oper) {
54
+ return () => {
55
+ instance.reorder(oper)
56
+ }
51
57
  },
52
- updateOrder: function(){
53
- this.instance.find('input[name="'+this.manager.prefix+'-'+this.index+'-ORDER"]').val(this.order);
58
+ updateOrder: function () {
59
+ this.instance.find('input[name="' + this.manager.prefix + '-' + this.index + '-ORDER"]').val(this.order);
54
60
  }
55
61
  }
56
62
  }
63
+
57
64
  function gtformSetManager(instance) {
58
65
  var obj = {
59
66
  index: 0,
@@ -70,49 +77,61 @@ function gtformSetManager(instance) {
70
77
  formList: instance.find('.formlist'),
71
78
  template: '',
72
79
  prefix: 'form-',
73
- initialize: function(){
74
- this.template = this.formsetControl.find(".formsettemplate").contents()[0].data;
75
- this.prefix = this.formsetControl.data('prefix');
76
- this.validateMax = this.formsetControl.data('validate-max') == '1';
77
- this.validateMin = this.formsetControl.data('validate-min') == '1';
78
- this.loadManagementForm();
79
- this.instance.find('.formsetadd').on('click', this.addBtnForm(this));
80
- this.addFormDom();
81
- },
82
- addBtnForm: function(instance){
83
- return () => { instance.addEmtpyForm() };
84
- },
85
- addEmtpyForm: function(){
86
- if(this.validateAddForm()){
80
+ initialize: function () {
81
+ this.template = this.formsetControl.find(".formsettemplate").contents()[0].data;
82
+ this.prefix = this.formsetControl.data('prefix');
83
+ this.validateMax = this.formsetControl.data('validate-max') == '1';
84
+ this.validateMin = this.formsetControl.data('validate-min') == '1';
85
+ this.loadManagementForm();
86
+ this.instance.find('.formsetadd').on('click', this.addBtnForm(this));
87
+ this.addFormDom();
88
+ },
89
+ addBtnForm: function (instance) {
90
+ return (e) => {
91
+ instance.addEmtpyForm(e)
92
+ };
93
+ },
94
+ addEmtpyForm: function (e) {
95
+ if (this.validateAddForm()) {
96
+ this.activeForms += 1;
87
97
  var form = gtforms(this.index, this, this.formList);
88
98
  form.render();
89
99
  this.forms.push(form);
100
+ this.addForm(this, form, true, e);
90
101
  this.index += 1;
91
102
  this.updateTotalForms(+1);
92
- }else{
103
+ } else {
93
104
  this.notify('error', 'You cannot add new form, limit is exceded')
94
105
  }
95
106
  },
96
- addForm: function(object){},
97
- addFormDom: function(){
98
- this.formList.children().each((i, element) =>{
99
- var form = gtforms(this.index, this, this.formList, extra=false);
100
- form.instance = $(element);
101
- form.registerBtns();
102
- this.forms.push(form);
103
- this.index += 1;
107
+ addForm: function (parent, object, isempty, event) {
108
+ },
109
+ addFormDom: function () {
110
+ this.formList.children().each((i, element) => {
111
+ this.activeForms += 1;
112
+ var form = gtforms(this.index, this, this.formList, extra = false);
113
+ form.instance = $(element);
114
+ form.registerBtns();
115
+ this.forms.push(form);
116
+ this.addForm(this, form, false, null);
117
+ this.index += 1;
104
118
  });
105
119
  },
106
- deleteForm: function(index){
107
- if( !this.validateDeleteForm()) return;
108
- if(index>=0 && index < this.forms.length){
109
- if(this.forms[index].extra){
120
+ delForm: function (parent, index, form) {
121
+ },
122
+ deleteForm: function (index) {
123
+ if (!this.validateDeleteForm()) return;
124
+ this.activeForms = Math.max(0, this.activeForms - 1);
125
+
126
+ if (index >= 0 && index < this.forms.length) {
127
+ this.delForm(this, index, this.forms[index]);
128
+ if (this.forms[index].extra) {
110
129
  this.forms.splice(index, 1);
111
130
  this.updateTotalForms(-1);
112
- if(index == this.forms.length){
131
+ if (index == this.forms.length) {
113
132
  this.index -= 1;
114
- }else{
115
- for(var x=0; x<this.forms.length; x++){
133
+ } else {
134
+ for (var x = 0; x < this.forms.length; x++) {
116
135
  this.forms[x].order = x;
117
136
  this.forms[x].updateOrder();
118
137
  }
@@ -121,40 +140,40 @@ function gtformSetManager(instance) {
121
140
 
122
141
  }
123
142
  },
124
- validateAddForm: function(){
125
- if(!this.validateMax) return true;
143
+ validateAddForm: function () {
144
+ if (!this.validateMax) return true;
126
145
  return this.MAX_NUM_FORMS == -1 || this.TOTAL_FORMS < this.MAX_NUM_FORMS;
127
146
  },
128
- validateDeleteForm: function(){
129
- if(!this.validateMin) return true;
147
+ validateDeleteForm: function () {
148
+ if (!this.validateMin) return true;
130
149
  return this.MIN_NUM_FORMS == -1 || this.TOTAL_FORMS > this.MIN_NUM_FORMS;
131
150
  },
132
- loadManagementForm: function(){
133
- this.TOTAL_FORMS = parseInt(this.formsetControl.find('input[name="'+this.prefix+'-TOTAL_FORMS"]').val());
134
- this.INITIAL_FORMS = parseInt(this.formsetControl.find('input[name="'+this.prefix+'-INITIAL_FORMS"]').val());
135
- this.MIN_NUM_FORMS = parseInt(this.formsetControl.find('input[name="'+this.prefix+'-MIN_NUM_FORMS"]').val());
136
- this.MAX_NUM_FORMS = parseInt(this.formsetControl.find('input[name="'+this.prefix+'-MAX_NUM_FORMS"]').val());
151
+ loadManagementForm: function () {
152
+ this.TOTAL_FORMS = parseInt(this.formsetControl.find('input[name="' + this.prefix + '-TOTAL_FORMS"]').val());
153
+ this.INITIAL_FORMS = parseInt(this.formsetControl.find('input[name="' + this.prefix + '-INITIAL_FORMS"]').val());
154
+ this.MIN_NUM_FORMS = parseInt(this.formsetControl.find('input[name="' + this.prefix + '-MIN_NUM_FORMS"]').val());
155
+ this.MAX_NUM_FORMS = parseInt(this.formsetControl.find('input[name="' + this.prefix + '-MAX_NUM_FORMS"]').val());
137
156
  },
138
- updateManagementForm: function(){
139
- this.formsetControl.find('input[name="'+this.prefix+'-TOTAL_FORMS"]').val(this.TOTAL_FORMS);
140
- this.formsetControl.find('input[name="'+this.prefix+'-INITIAL_FORMS"]').val(this.INITIAL_FORMS);
141
- this.formsetControl.find('input[name="'+this.prefix+'-MIN_NUM_FORMS"]').val(this.MIN_NUM_FORMS);
142
- this.formsetControl.find('input[name="'+this.prefix+'-MAX_NUM_FORMS"]').val(this.MAX_NUM_FORMS);
157
+ updateManagementForm: function () {
158
+ this.formsetControl.find('input[name="' + this.prefix + '-TOTAL_FORMS"]').val(this.TOTAL_FORMS);
159
+ this.formsetControl.find('input[name="' + this.prefix + '-INITIAL_FORMS"]').val(this.INITIAL_FORMS);
160
+ this.formsetControl.find('input[name="' + this.prefix + '-MIN_NUM_FORMS"]').val(this.MIN_NUM_FORMS);
161
+ this.formsetControl.find('input[name="' + this.prefix + '-MAX_NUM_FORMS"]').val(this.MAX_NUM_FORMS);
143
162
  },
144
- updateTotalForms: function(oper){
145
- this.TOTAL_FORMS = this.TOTAL_FORMS+oper;
146
- this.formsetControl.find('input[name="'+this.prefix+'-TOTAL_FORMS"]').val(this.TOTAL_FORMS);
163
+ updateTotalForms: function (oper) {
164
+ this.TOTAL_FORMS = this.TOTAL_FORMS + oper;
165
+ this.formsetControl.find('input[name="' + this.prefix + '-TOTAL_FORMS"]').val(this.TOTAL_FORMS);
147
166
  },
148
- getForm: function(index){
149
- if(index>=0 && index < this.forms.length){
167
+ getForm: function (index) {
168
+ if (index >= 0 && index < this.forms.length) {
150
169
  return this.forms[index];
151
170
  }
152
171
  return null;
153
172
  },
154
- switchFrom: function(fref, fswap){
173
+ switchFrom: function (fref, fswap) {
155
174
  var freform = this.getForm(fref);
156
175
  var fswapform = this.getForm(fswap);
157
- if(freform != null && fswapform != null){
176
+ if (freform != null && fswapform != null) {
158
177
  var tmporder = freform.order;
159
178
  freform.order = fswapform.order;
160
179
  fswapform.order = tmporder;
@@ -166,23 +185,23 @@ function gtformSetManager(instance) {
166
185
  }
167
186
 
168
187
  },
169
- redrawOrdering: function(){
170
- for(var x=0; x<this.forms.length; x++){
171
- this.formList.append(this.forms[x].instance);
188
+ redrawOrdering: function () {
189
+ for (var x = 0; x < this.forms.length; x++) {
190
+ this.formList.append(this.forms[x].instance);
172
191
  }
173
192
  },
174
- notify: function(type, text){
193
+ notify: function (type, text) {
175
194
  console.log(text);
176
195
  },
177
- clean: function(){
178
- while(this.forms.length>0){
196
+ clean: function () {
197
+ while (this.forms.length > 0) {
179
198
  var f = this.forms.pop();
180
199
  f.instance.remove();
181
200
  }
182
- this.TOTAL_FORMS=0;
183
- this.INITIAL_FORMS=0;
184
- this.TOTAL_FORMS=0;
185
- this.index=0;
201
+ this.TOTAL_FORMS = 0;
202
+ this.INITIAL_FORMS = 0;
203
+ this.TOTAL_FORMS = 0;
204
+ this.index = 0;
186
205
  this.updateManagementForm();
187
206
  }
188
207
  }