create_duplicaterule.html
1 <div id="template-row" style="display: none">
2 <div class="row template-child">
3 <div class="col-2">
4 <select class="form-select selected-attribute-treatment-type" name="selected_attribute_treatment_type_">
5 <#list available_rule_types as rule_type >
6 <option value="${rule_type.label!''}">${rule_type.label!''}</option>
7 </#list>
8 </select>
9 </div>
10 <div class="col-9">
11 <select id="selected_attribute_treatment_attributes_" class="form-select selected-attribute-treatment-attributes" multiple data-allow-clear="true" data-clear-label="Clear" name="selected_attribute_treatment_attributes_" data-suggestions-threshold="0">
12 <#list available_attributes as attribute >
13 <option value="${attribute.keyName!''}">${attribute.name!''}</option>
14 </#list>
15 </select>
16 <div class="invalid-feedback">Please select a valid tag.</div>
17 </div>
18 <div class="col-1">
19 <a class="btn btn-default btn-delete-row">
20 Supp
21 </a>
22 </div>
23 </div>
24 </div>
25 <@box>
26 <@boxHeader title='#i18n{identitystore.create_duplicaterule.title}' />
27 <@boxBody>
28 <@messages infos=infos />
29 <@tform name='create_duplicaterule' action='jsp/admin/plugins/identitystore/ManageDuplicateRules.jsp' >
30
31 <@messages errors=errors />
32 <@input type="hidden" value="${token}" name="token" />
33 <@input type="hidden" value="${duplicaterule.id!}" name="id" id="id"/>
34
35 <@formGroup labelFor='code' labelKey='#i18n{identitystore.create_duplicaterule.labelCode}' mandatory=true>
36 <@input type='text' id='code' name='code' value='${duplicaterule.code!\'\'}' tabIndex='0' />
37 </@formGroup>
38
39 <@formGroup labelFor='name' labelKey='#i18n{identitystore.create_duplicaterule.labelName}' mandatory=true>
40 <@input type='text' id='name' name='name' value='${duplicaterule.name!\'\'}' tabIndex='1' />
41 </@formGroup>
42
43 <@formGroup labelFor='description' labelKey='#i18n{identitystore.create_duplicaterule.labelDescription}' mandatory=false>
44 <@input type='textarea' id='description' name='description' value='${duplicaterule.description!\'\'}' tabIndex='2' />
45 </@formGroup>
46
47 <@formGroup labelFor='priority' labelKey='#i18n{identitystore.create_duplicaterule.labelPriority}' mandatory=true>
48 <@input type='text' id='priority' name='priority' value='${duplicaterule.priority!\'\'}' tabIndex='3' />
49 </@formGroup>
50
51 <@formGroup labelFor='detectionLimit' labelKey='#i18n{identitystore.create_duplicaterule.labelDetectionLimit}' helpKey='#i18n{identitystore.create_duplicaterule.labelDetectionLimit.help}' mandatory=true>
52 <@input type='text' id='detectionLimit' name='detectionLimit' value='${duplicaterule.detectionLimit!\'\'}' tabIndex='4' />
53 </@formGroup>
54
55 <div class="form-group mb-3">
56 <label class="form-label required col-sm-12 col-lg-3 form-label text-right " for="cb-active">
57 #i18n{identitystore.create_duplicaterule.labelActive} <i class="ti ti-help" style="font-size: large;" title="#i18n{identitystore.create_duplicaterule.labelActiveHelp}"></i>
58 </label>
59 <input type="checkbox" id="cb-active" name="active" <#if duplicaterule.active>checked</#if> >
60 </div>
61
62 <div class="form-group mb-3">
63 <label class="form-label required col-sm-12 col-lg-3 form-label text-right " for="cb-daemon">
64 #i18n{identitystore.create_duplicaterule.labelDaemon} <i class="ti ti-help" style="font-size: large;" title="#i18n{identitystore.create_duplicaterule.labelDaemonHelp}"></i>
65 </label>
66 <input type="checkbox" id="cb-daemon" name="daemon" <#if duplicaterule.daemon>checked</#if> >
67 </div>
68
69 <@formGroup labelFor='nbFilledAttributes' labelKey='#i18n{identitystore.create_duplicaterule.labelNbFilledAttributes}' mandatory=true>
70 <@input type='text' id='nbFilledAttributes' name='nbFilledAttributes' value='${duplicaterule.nbFilledAttributes!\'\'}' tabIndex='5' />
71 </@formGroup>
72
73 <@formGroup labelFor='nbEqualAttributes' labelKey='#i18n{identitystore.create_duplicaterule.labelNbEqualAttributes}' mandatory=true>
74 <@input type='text' id='nbEqualAttributes' name='nbEqualAttributes' value='${duplicaterule.nbEqualAttributes!\'\'}' tabIndex='6' />
75 </@formGroup>
76
77 <@formGroup labelFor='nbMissingAttributes' labelKey='#i18n{identitystore.create_duplicaterule.labelNbMissingAttributes}' mandatory=true>
78 <@input type='text' id='nbMissingAttributes' name='nbMissingAttributes' value='${duplicaterule.nbMissingAttributes!\'\'}' tabIndex='7' />
79 </@formGroup>
80
81 <@formGroup labelFor='select-checked-attribute' labelKey='#i18n{identitystore.create_duplicaterule.labelCheckedKeys}' mandatory=true>
82 <select class="form-select" id="select-checked-attribute" multiple data-allow-clear="true" data-clear-label="Clear" name="selected_checked_attributes" data-suggestions-threshold="0">
83 <#list available_attributes as attribute >
84 <option value="${attribute.keyName!''}" <#if rule_checked_attributes?seq_contains(attribute.keyName!'')> selected="selected"</#if>>${attribute.name!''}</option>
85 </#list>
86 </select>
87 <div class="invalid-feedback">Please select a valid tag.</div>
88 </@formGroup>
89
90 <@formGroup labelKey='#i18n{identitystore.create_duplicaterule.labelAttributeTreatments}' mandatory=false>
91 <a id="btn-add-attribute-treatment-row" class="btn btn-default">
92 Ajouter un traitement
93 </a>
94 <div id="attribute_treatments_definition" class="col-12">
95 <#list duplicaterule.attributeTreatments as attributeTreatment>
96 <div class="row attribute-treatment-definition-row">
97 <div class="col-2">
98 <select class="form-select" name="selected_attribute_treatment_type_${attributeTreatment?index}">
99 <#list available_rule_types as rule_type >
100 <option value="${rule_type.label!''}" <#if rule_type == attributeTreatment.type> selected="selected"</#if>>${rule_type.label!''}</option>
101 </#list>
102 </select>
103 </div>
104 <div class="col-9">
105 <select id="selected_attribute_treatment_attributes_${attributeTreatment?index}" class="form-select" multiple data-allow-clear="true" data-clear-label="Clear" name="selected_attribute_treatment_attributes_${attributeTreatment?index}" data-suggestions-threshold="0">
106 <#list available_attributes as attribute >
107 <option value="${attribute.keyName!''}" <#if attributeTreatment.attributeKeysStr?seq_contains(attribute.keyName!'')> selected="selected"</#if>>${attribute.name!''}</option>
108 </#list>
109 </select>
110 <div class="invalid-feedback">Please select a valid tag.</div>
111 </div>
112 <div class="col-1">
113 <a class="btn btn-default btn-delete-row">
114 Supp
115 </a>
116 </div>
117 </div>
118 </#list>
119 </div>
120 </@formGroup>
121
122
123 <@actionButtons button1Name="${action}" button2Name="view_manageDuplicateRules"/>
124 </@tform>
125 </@boxBody>
126 </@box>
127
128 <!-- See https://www.cssscript.com/tags-input-bootstrap-5/ -->
129 <script type="module">
130 import Tags from "./js/admin/plugins/identitystore/tags.js";
131
132 Tags.init("#select-checked-attribute");
133 const nbInitRows = $('.attribute-treatment-definition-row').length;
134 for (let i = 0; i < nbInitRows; i++) {
135 Tags.init("#selected_attribute_treatment_attributes_" + i);
136 }
137
138 $('#btn-add-attribute-treatment-row').click(function () {
139 const nbRows = $('.attribute-treatment-definition-row').length;
140 let clone = $('#template-row').clone();
141 let type = clone.find(".selected-attribute-treatment-type");
142 type.attr("name", "selected_attribute_treatment_type_" + nbRows);
143 type.attr("id", "selected_attribute_treatment_type_" + nbRows);
144 let attributes = clone.find(".selected-attribute-treatment-attributes");
145 attributes.attr("name", "selected_attribute_treatment_attributes_" + nbRows);
146 attributes.attr("id", "selected_attribute_treatment_attributes_" + nbRows);
147 let firstRow = clone.find(".template-child");
148 firstRow.addClass("attribute-treatment-definition-row")
149 firstRow.removeClass("template-child")
150 $('#attribute_treatments_definition').append(clone.children());
151 Tags.init("#selected_attribute_treatment_attributes_" + nbRows);
152 });
153
154 $(document).on('click', '.btn-delete-row', function() {
155 $(this).parents(".attribute-treatment-definition-row").remove();
156 });
157
158 </script>