Commit fe66bb39 by Van

feat(all) : Add checbox "Tous les champs". Add autocomplete on field add search

parent 7c03595b
...@@ -4,10 +4,26 @@ ...@@ -4,10 +4,26 @@
.border-none { .border-none {
border: none !important; border: none !important;
} }
.allCheckbox{
display: flex;
float: left;
margin-right: 6px;
}
.allCheckbox label{
margin-right: 1em;
}
.chooseField { .chooseField {
height: 26px !important; height: 26px !important;
} }
.select span{
width: 20em;
text-align: center;
}
.addContentTypeContainer { .addContentTypeContainer {
margin-bottom: 30px; margin-bottom: 30px;
} }
......
...@@ -33,6 +33,7 @@ class CustomQueries { ...@@ -33,6 +33,7 @@ class CustomQueries {
listContentTypeContainer: '.listContentTypeContainer-'+this.name, listContentTypeContainer: '.listContentTypeContainer-'+this.name,
removeContentTypeBtn: '#removeContentType-'+this.name, removeContentTypeBtn: '#removeContentType-'+this.name,
addFieldBtn: '#addField-'+this.name, addFieldBtn: '#addField-'+this.name,
allFields: '#allFields-'+this.name,
validateFieldBtn: '#validateField-'+this.name, validateFieldBtn: '#validateField-'+this.name,
cancelFieldBtn: '#cancelField-'+this.name, cancelFieldBtn: '#cancelField-'+this.name,
removeFieldBtn: '#removeField-'+this.name, removeFieldBtn: '#removeField-'+this.name,
...@@ -59,10 +60,13 @@ class CustomQueries { ...@@ -59,10 +60,13 @@ class CustomQueries {
loadOriginalContent() { loadOriginalContent() {
let content = this.json; let content = this.json;
for(let index in content) { for(let index in content) {
this.createContentTypeBlock(index); if (index != 'all'){
this.loadOriginalField(index, content[index], content) this.createContentTypeBlock(index);
this.loadOriginalField(index, content[index], content)
}
} }
} }
/** /**
* INIT JSON content for fields * INIT JSON content for fields
* @param contentType * @param contentType
...@@ -84,6 +88,7 @@ class CustomQueries { ...@@ -84,6 +88,7 @@ class CustomQueries {
this.loadOriginalFieldContent(contentType, index, fields[index]); this.loadOriginalFieldContent(contentType, index, fields[index]);
} }
} }
/** /**
* INIT JSON content for fields content * INIT JSON content for fields content
* @param contentType * @param contentType
...@@ -126,6 +131,10 @@ class CustomQueries { ...@@ -126,6 +131,10 @@ class CustomQueries {
createContentTypeBlock(contentType) { createContentTypeBlock(contentType) {
if(!this.usedContentType[contentType] && contentType) { if(!this.usedContentType[contentType] && contentType) {
this.usedContentType[contentType] = []; this.usedContentType[contentType] = [];
let checked = "";
if (jQuery.inArray(contentType, this.json['all']) !== -1) {
checked = "checked";
}
$(this.selectors.listContentTypeContainer).append( $(this.selectors.listContentTypeContainer).append(
`<fieldset class="bolt-field-repeater"> `<fieldset class="bolt-field-repeater">
<div class="repeater-slot contentType ${contentType}"> <div class="repeater-slot contentType ${contentType}">
...@@ -144,6 +153,10 @@ class CustomQueries { ...@@ -144,6 +153,10 @@ class CustomQueries {
</div> </div>
</div> </div>
<div class="btn-group"> <div class="btn-group">
<div class="allCheckbox">
<label for="allFields">Tous les champs</label>
<input ${checked} type="checkbox" name="allFields" class="${checked}" id="allFields-${this.name}-${contentType}">
</div>
<button type="button" class="btn btn-sm btn-default" id="addField-${this.name}-${contentType}"> <button type="button" class="btn btn-sm btn-default" id="addField-${this.name}-${contentType}">
<i class="fa fa-plus"></i> Ajouter un champ <i class="fa fa-plus"></i> Ajouter un champ
</button> </button>
...@@ -173,6 +186,7 @@ class CustomQueries { ...@@ -173,6 +186,7 @@ class CustomQueries {
</div> </div>
</fieldset>` </fieldset>`
); );
this.initEventClickAllFields(contentType);
this.initEventClickBtnRemoveContentType(contentType); this.initEventClickBtnRemoveContentType(contentType);
this.initEventClickBtnAddField(contentType); this.initEventClickBtnAddField(contentType);
} }
...@@ -319,6 +333,16 @@ class CustomQueries { ...@@ -319,6 +333,16 @@ class CustomQueries {
this.rebuildJson(); this.rebuildJson();
}); });
} }
/**
* @param contentType
*/
initEventClickAllFields(contentType){
$(this.selectors.allFields+'-'+contentType).on('click', (e) => {
this.rebuildJson();
});
}
/** /**
* Field add event * Field add event
* @param contentType * @param contentType
...@@ -340,7 +364,8 @@ class CustomQueries { ...@@ -340,7 +364,8 @@ class CustomQueries {
} }
} }
$(this.selectors.listContentTypeContainer+' .contentType.'+contentType+' .headField').show(); $(this.selectors.listContentTypeContainer+' .contentType.'+contentType+' .headField').show();
}); });
$('.chooseField').select2();
// Field validate btn // Field validate btn
$(this.selectors.validateFieldBtn+'-'+contentType).on('click', (e) => { $(this.selectors.validateFieldBtn+'-'+contentType).on('click', (e) => {
...@@ -415,7 +440,9 @@ class CustomQueries { ...@@ -415,7 +440,9 @@ class CustomQueries {
* Rebuild Json data * Rebuild Json data
*/ */
rebuildJson() { rebuildJson() {
let json = {}; let json = {
all: {}
};
$('.tags').each(function () { $('.tags').each(function () {
let id = $(this).attr('id').split('-'); let id = $(this).attr('id').split('-');
let value = $(this).select2('val'); let value = $(this).select2('val');
...@@ -435,6 +462,12 @@ class CustomQueries { ...@@ -435,6 +462,12 @@ class CustomQueries {
json[id[1]][id[2]][id[3]] = value; json[id[1]][id[2]][id[3]] = value;
} }
}); });
$('.allCheckbox input').each(function () {
if($(this).is(':checked')) {
let contentType = $(this).attr('id').replace('allFields-list-', '');
json.all.push(contentType);
}
});
/*console.log(json);*/ /*console.log(json);*/
this.element.val(JSON.stringify(json)); this.element.val(JSON.stringify(json));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment