@@ -46,55 +46,68 @@ document.addEventListener("turbo:load", function () {
4646 <tr
4747 class="field-row group relative flex flex-col bg-white transition-colors hover:bg-gray-50/50 border-b border-gray-600 last-of-type:border-b-0 lg:table-row lg:border-none"
4848 data-field-index="${ index } "
49+ data-controller="project-template-fields"
4950 >
5051 <td class="block lg:table-cell px-6 lg:pl-12 lg:pr-6 py-5 whitespace-nowrap align-top">
5152 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Field Label</span>
5253 <div class="relative">
5354 <textarea
54- name="project_template[project_template_fields_attributes][${ index } ][label]"
55- placeholder="e.g. Project Title"
56- rows="1"
57- class="block w-full px-3 py-2.5 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm resize-none overflow-hidden"
58- data-controller="textarea-resize"
59- data-action="input->textarea-resize#resize"
55+ name="project_template[project_template_fields_attributes][${ index } ][label]"
56+ placeholder="e.g. Project Title"
57+ rows="1"
58+ class="block w-full px-3 py-2.5 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm resize-none overflow-hidden"
59+ data-controller="textarea-resize"
60+ data-action="input->textarea-resize#resize"
6061 ></textarea>
6162
62- <button type="button" class="remove-field hidden lg:flex items-center justify-center absolute -left-10 top-1/2 -translate-y-1/2 w-8 h-8 text-gray-400 opacity-60 hover:opacity-100 hover:bg-red-50 hover:text-red-600 rounded-md transition-all" title="Remove Field">
63- <svg class="h-5 w-5 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
63+ <button
64+ type="button"
65+ class="remove-field hidden lg:flex items-center justify-center absolute -left-10 top-1/2 -translate-y-1/2 w-8 h-8 text-gray-400 opacity-60 hover:opacity-100 hover:bg-red-50 hover:text-red-600 rounded-md transition-all"
66+ title="Remove Field"
67+ >
68+ <svg class="h-5 w-5 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
69+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
70+ </svg>
6471 </button>
6572 </div>
6673 </td>
6774
6875 <td class="block lg:table-cell px-6 py-5 align-top">
6976 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Hint Text</span>
70- <textarea name="project_template[project_template_fields_attributes][${ index } ][hint]"
71- placeholder="Instructions..."
72- rows="1"
73- class="block w-full px-3 py-2.5 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm resize-none overflow-hidden"
74- data-controller="textarea-resize"
75- data-action="input->textarea-resize#resize"
77+ <textarea
78+ name="project_template[project_template_fields_attributes][${ index } ][hint]"
79+ placeholder="Instructions..."
80+ rows="1"
81+ class="block w-full px-3 py-2.5 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm resize-none overflow-hidden"
82+ data-controller="textarea-resize"
83+ data-action="input->textarea-resize#resize"
7684 ></textarea>
7785 </td>
7886
7987 <td class="block lg:table-cell px-6 py-5 whitespace-nowrap align-top">
8088 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Field Type</span>
81- <select name="project_template[project_template_fields_attributes][${ index } ][field_type]" class="field-type-select block w-full py-2.5 pl-3 pr-8 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm cursor-pointer">
89+ <select
90+ name="project_template[project_template_fields_attributes][${ index } ][field_type]"
91+ class="field-type-select block w-full py-2.5 pl-3 pr-2.5 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm cursor-pointer"
92+ >
8293 <option value="">Select field type</option>
8394 ${ generateFieldTypeOptions ( ) }
8495 </select>
8596 </td>
8697
8798 <td class="block lg:table-cell px-6 py-5 whitespace-nowrap align-top">
8899 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Applicable To</span>
89- <select name="project_template[project_template_fields_attributes][${ index } ][applicable_to]"
90- class="block w-full py-2.5 pl-3 pr-8 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm cursor-pointer">
100+ <select
101+ name="project_template[project_template_fields_attributes][${ index } ][applicable_to]"
102+ class="block w-full py-2.5 pl-3 pr-8 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm cursor-pointer"
103+ >
91104 ${ generateApplicableToOptions ( ) }
92105 </select>
93106 </td>
94107
95- <td class="block lg:table-cell px-6 py-5 align-top">
108+ <td class="block lg:table-cell px-6 py-5 align-top" data-project-template-fields-target="optionsContainer" >
96109 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Options</span>
97-
110+
98111 <div class="options-section hidden w-full">
99112 <button type="button"
100113 class="add-option-btn text-[0.8125rem] text-gray-500 bg-transparent border border-dashed border-gray-300 rounded py-2 px-3 cursor-pointer transition-all duration-150 ease-in-out w-fit hover:text-blue-600 hover:border-blue-500 hover:bg-[#f8f9fa] mt-2"
@@ -106,20 +119,36 @@ document.addEventListener("turbo:load", function () {
106119 </div>
107120
108121 <button type="button" class="remove-field lg:hidden mt-3 inline-flex items-center text-xs text-red-500 hover:text-red-700 font-medium bg-red-50 px-3 py-2 rounded-md">
109- <svg class="mr-1.5 h-4 w-4 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
122+ <svg class="mr-1.5 h-4 w-4 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
123+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
124+ </svg>
110125 Remove Field
111126 </button>
127+ <input type="hidden" name="project_template[project_template_fields_attributes][${ index } ][_destroy]" value="0" class="destroy-flag">
112128 </td>
113129
114- <td class="block lg:table-cell px-6 py-5 align-top">
130+ <td class="block lg:table-cell px-6 py-5 whitespace-nowrap align-top">
115131 <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Required</span>
116- <input type="hidden"
117- name="project_template[project_template_fields_attributes][${ index } ][required]"
118- value="false">
119- <input type="checkbox"
120- name="project_template[project_template_fields_attributes][${ index } ][required]"
121- value="true"
122- class="block w-full py-2.5 pl-3 pr-8 border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm cursor-pointer">
132+ <div class="flex items-center h-10">
133+ <input type="hidden" name="project_template[project_template_fields_attributes][${ index } ][required]" value="0">
134+ <input type="checkbox"
135+ name="project_template[project_template_fields_attributes][${ index } ][required]"
136+ value="1"
137+ class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500 cursor-pointer">
138+ <label class="ml-2 text-sm text-gray-600 lg:hidden">Field is required</label>
139+ </div>
140+ </td>
141+
142+ <td class="block lg:table-cell px-6 py-5 whitespace-nowrap align-top">
143+ <span class="lg:hidden text-xs font-bold text-gray-500 uppercase tracking-wide mb-1 block">Free Edit</span>
144+ <div class="flex items-center h-10" title="Allow editing after approval">
145+ <input type="hidden" name="project_template[project_template_fields_attributes][${ index } ][free_edit]" value="0">
146+ <input type="checkbox"
147+ name="project_template[project_template_fields_attributes][${ index } ][free_edit]"
148+ value="1"
149+ class="h-5 w-5 rounded border-gray-300 text-green-600 focus:ring-green-500 cursor-pointer">
150+ <label class="ml-2 text-sm text-gray-600 lg:hidden">Editable after approval</label>
151+ </div>
123152 </td>
124153 </tr>
125154 ` ;
0 commit comments