Commit c9a440a1d1de17965a5cee22ec89c89c6df12d61
1 parent
22f5df84fd
Exists in
master
and in
1 other branch
Образование, табы, 2-часть
Showing 4 changed files with 50 additions and 34 deletions Side-by-side Diff
app/Http/Controllers/Admin/EducationController.php
resources/views/admin/education/form.blade.php
... | ... | @@ -147,6 +147,7 @@ |
147 | 147 | @endphp |
148 | 148 | |
149 | 149 | @foreach ($program as $pro) |
150 | + @php $name_tab = $pro->level; @endphp | |
150 | 151 | @if ((!empty($level)) && ($level <> $pro->level)) |
151 | 152 | </tbody> |
152 | 153 | </table> |
... | ... | @@ -156,7 +157,14 @@ |
156 | 157 | |
157 | 158 | @if ($bool == true) |
158 | 159 | <div class="tabs__item js_tabs_item @php echo($i>1) ? 'hidden' : ''; @endphp" data-id="{{$i}}"> |
159 | - <table class="mb-4 w-full whitespace-no-wrap"> | |
160 | + <form action="{{ route('admin.add-program-education') }}" method="GET" class="flex flex-col flex-wrap mb-4 md:flex-row md:space-x-4"> | |
161 | + <div> | |
162 | + <input type="hidden" name="id" value="{{ $education->id }}"/> | |
163 | + <input type="hidden" name="level" value="{{$name_tab}}"/> | |
164 | + <button type="submit" class="mt-4 px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">Добавить</button> | |
165 | + </div> | |
166 | + </form> | |
167 | + <table class="mb-4 w-full whitespace-no-wrap"> | |
160 | 168 | <thead> |
161 | 169 | <tr |
162 | 170 | class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" |
... | ... | @@ -180,18 +188,17 @@ |
180 | 188 | <div> |
181 | 189 | <p class="font-semibold">Специальность: </p> |
182 | 190 | <p class="text-xs text-gray-600 dark:text-gray-400"> |
183 | - {{$pro->name}} | |
191 | + {{ mb_strimwidth($pro->name, 0, 50, "...") }} | |
184 | 192 | </p> |
185 | 193 | </div> |
186 | 194 | </div> |
187 | 195 | </td> |
188 | 196 | <td class="px-4 py-3 text-sm"> |
189 | - <span class="text-gray-700 dark:text-gray-400">Описание: {{$pro->text}}</span> | |
197 | + <span class="text-gray-700 dark:text-gray-400">Описание: {{ mb_strimwidth($pro->text, 0, 100, "...")}}</span> | |
190 | 198 | </td> |
191 | 199 | <td class="px-4 py-3 text-xs"> |
192 | 200 | <a href="{{ route('admin.edit-program-education', ['program' => $pro->id, 'education' => $education->id]) }}">Изменить</a> | |
193 | 201 | <a href="{{ route('admin.delete-program-education', ['program' => $pro->id, 'education' => $education->id]) }}">Удалить</a> |
194 | - | |
195 | 202 | </td> |
196 | 203 | </tr> |
197 | 204 | @endforeach |
... | ... | @@ -201,9 +208,9 @@ |
201 | 208 | @endisset |
202 | 209 | </div> |
203 | 210 | |
204 | -<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> | |
211 | +<!--<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script>--> | |
205 | 212 | |
206 | -<!--<script src="{{ asset('./ckeditor/ckeditor.js') }}"></script>--> | |
213 | +<script src="{{ asset('./ckeditor/ckeditor.js') }}"></script> | |
207 | 214 | <script> |
208 | 215 | CKEDITOR.replace( 'text', { |
209 | 216 | filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", |
... | ... | @@ -233,7 +240,13 @@ |
233 | 240 | const tabsBtns = tabsButtons.querySelectorAll('.js_tabs_btn'); |
234 | 241 | const id = Date.now(); |
235 | 242 | |
236 | - if (tabsInput.dataset.edit) { | |
243 | + | |
244 | + if (tabsBtns.length >= qty) { | |
245 | + console.log('Ветка выполнена'); | |
246 | + e.preventDefault(); | |
247 | + } | |
248 | + | |
249 | + /*if (tabsInput.dataset.edit) { | |
237 | 250 | |
238 | 251 | tabsBtns.forEach(btn => { |
239 | 252 | if (tabsInput.dataset.edit === btn.dataset.id) { |
... | ... | @@ -267,7 +280,7 @@ |
267 | 280 | tabsContent.innerHTML += getTabsItemTemplate(id, 'hidden'); |
268 | 281 | } |
269 | 282 | } |
270 | - } | |
283 | + }*/ | |
271 | 284 | |
272 | 285 | tabsInput.value = ''; |
273 | 286 | addDisabledBtnStatus(tabsSubmitBtn); |
... | ... | @@ -275,13 +288,11 @@ |
275 | 288 | }); |
276 | 289 | |
277 | 290 | tabsInput.addEventListener('input', () => { |
278 | - | |
279 | - if (tabsInput.value !== '') { | |
280 | - removeDisabledBtnStatus(tabsSubmitBtn); | |
281 | - } else { | |
282 | - addDisabledBtnStatus(tabsSubmitBtn); | |
283 | - } | |
284 | - | |
291 | + if (tabsInput.value !== '') { | |
292 | + removeDisabledBtnStatus(tabsSubmitBtn); | |
293 | + } else { | |
294 | + addDisabledBtnStatus(tabsSubmitBtn); | |
295 | + } | |
285 | 296 | }); |
286 | 297 | |
287 | 298 | tabsButtons.addEventListener('click', (e) => { |
... | ... | @@ -305,17 +316,13 @@ |
305 | 316 | }); |
306 | 317 | |
307 | 318 | tabsButtons.addEventListener('dblclick', (e) => { |
319 | + const target = e.target.closest('.js_tabs_btn'); | |
308 | 320 | |
309 | - const target = e.target.closest('.js_tabs_btn'); | |
310 | - | |
311 | - if (target) { | |
312 | - | |
313 | - tabsInput.value = target.dataset.btn; | |
314 | - tabsInput.dataset.edit = target.dataset.id; | |
315 | - removeDisabledBtnStatus(tabsSubmitBtn); | |
316 | - | |
317 | - } | |
318 | - | |
321 | + if (target) { | |
322 | + tabsInput.value = target.dataset.btn; | |
323 | + tabsInput.dataset.edit = target.dataset.id; | |
324 | + removeDisabledBtnStatus(tabsSubmitBtn); | |
325 | + } | |
319 | 326 | }); |
320 | 327 | |
321 | 328 | function getTabsBtnTemplate(btnName, id) { |
... | ... | @@ -441,21 +448,21 @@ |
441 | 448 | } |
442 | 449 | |
443 | 450 | function addDisabledBtnStatus(btn) { |
444 | - btn.disabled = true; | |
445 | - btn.classList.add('opacity-50', 'cursor-not-allowed'); | |
446 | - btn.classList.remove('active:bg-purple-600', 'hover:bg-purple-700', 'focus:shadow-outline-purple'); | |
451 | + btn.disabled = true; | |
452 | + btn.classList.add('opacity-50', 'cursor-not-allowed'); | |
453 | + btn.classList.remove('active:bg-purple-600', 'hover:bg-purple-700', 'focus:shadow-outline-purple'); | |
447 | 454 | } |
448 | 455 | |
449 | 456 | function removeDisabledBtnStatus(btn) { |
450 | - btn.disabled = false; | |
451 | - btn.classList.remove('opacity-50', 'cursor-not-allowed'); | |
452 | - btn.classList.add('active:bg-purple-600', 'hover:bg-purple-700', 'focus:shadow-outline-purple'); | |
457 | + btn.disabled = false; | |
458 | + btn.classList.remove('opacity-50', 'cursor-not-allowed'); | |
459 | + btn.classList.add('active:bg-purple-600', 'hover:bg-purple-700', 'focus:shadow-outline-purple'); | |
453 | 460 | } |
454 | 461 | |
455 | 462 | } |
456 | - | |
457 | 463 | console.log('main.js init'); |
458 | 464 | |
459 | 465 | }); |
466 | + | |
460 | 467 | </script> |
461 | 468 |
resources/views/admin/education/program-edit.blade.php
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> |
8 | 8 | <input type="hidden" id="education_id" name="education_id" value="{{ $id_education }}"/> |
9 | - <input type="hidden" id="level" name="level" value="{{ $program->name }}"/> | |
9 | + <input type="hidden" id="level" name="level" value="{{ $program->level }}"/> | |
10 | 10 | |
11 | 11 | <label class="block text-sm"> |
12 | 12 | <span class="text-gray-700 dark:text-gray-400">Название специализации</span> |
... | ... | @@ -37,6 +37,11 @@ |
37 | 37 | <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> |
38 | 38 | Сохранить |
39 | 39 | </button> |
40 | + | |
41 | + <a href="{{ route('admin.education.edit', ['education' => $id_education]) }}" | |
42 | + class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" | |
43 | + style="display: -webkit-inline-box; height: 30px!important;" | |
44 | + >Назад</a> | |
40 | 45 | </div> |
41 | 46 | </div> |
42 | 47 | </div> |
resources/views/admin/education/program.blade.php
... | ... | @@ -37,6 +37,11 @@ |
37 | 37 | <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> |
38 | 38 | Сохранить |
39 | 39 | </button> |
40 | + | |
41 | + <a href="{{ route('admin.education.edit', ['education' => $id_education]) }}" | |
42 | + class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" | |
43 | + style="display: -webkit-inline-box; height: 30px!important;" | |
44 | + >Назад</a> | |
40 | 45 | </div> |
41 | 46 | </div> |
42 | 47 | </div> |