Apply the new color selection component to services.

This commit is contained in:
Alex Tselegidis 2022-01-18 18:54:44 +01:00
parent a72dd9edb5
commit 73a6c791ec
2 changed files with 10 additions and 0 deletions

View file

@ -125,6 +125,10 @@
<input id="location" class="form-control"> <input id="location" class="form-control">
</div> </div>
<div class="mb-3">
<?php component('color_selection', ['attributes' => 'id="color"']) ?>
</div>
<div class="mb-3"> <div class="mb-3">
<label class="form-label" for="description"> <label class="form-label" for="description">
<?= lang('description') ?> <?= lang('description') ?>

View file

@ -27,6 +27,7 @@ App.Pages.Services = (function () {
const $location = $('#location'); const $location = $('#location');
const $description = $('#description'); const $description = $('#description');
const $filterServices = $('#filter-services'); const $filterServices = $('#filter-services');
const $color = $('#color');
let filterResults = {}; let filterResults = {};
let filterLimit = 20; let filterLimit = 20;
@ -129,6 +130,7 @@ App.Pages.Services = (function () {
currency: $currency.val(), currency: $currency.val(),
description: $description.val(), description: $description.val(),
location: $location.val(), location: $location.val(),
color: App.Components.ColorSelection.getColor($color),
availabilities_type: $availabilitiesType.val(), availabilities_type: $availabilitiesType.val(),
attendants_number: $attendantsNumber.val(), attendants_number: $attendantsNumber.val(),
id_categories: $category.val() || null id_categories: $category.val() || null
@ -154,6 +156,7 @@ App.Pages.Services = (function () {
$services.find('.record-details').find('input, select, textarea').prop('disabled', false); $services.find('.record-details').find('input, select, textarea').prop('disabled', false);
$filterServices.find('button').prop('disabled', true); $filterServices.find('button').prop('disabled', true);
$filterServices.find('.results').css('color', '#AAA'); $filterServices.find('.results').css('color', '#AAA');
App.Components.ColorSelection.enable($color);
}); });
/** /**
@ -263,6 +266,8 @@ App.Pages.Services = (function () {
$services.find('.record-details .is-invalid').removeClass('is-invalid'); $services.find('.record-details .is-invalid').removeClass('is-invalid');
$services.find('.record-details .form-message').hide(); $services.find('.record-details .form-message').hide();
App.Components.ColorSelection.disable($color);
} }
/** /**
@ -280,6 +285,7 @@ App.Pages.Services = (function () {
$location.val(service.location); $location.val(service.location);
$availabilitiesType.val(service.availabilities_type); $availabilitiesType.val(service.availabilities_type);
$attendantsNumber.val(service.attendants_number); $attendantsNumber.val(service.attendants_number);
App.Components.ColorSelection.setColor($color, service.color);
const categoryId = service.id_categories !== null ? service.id_categories : ''; const categoryId = service.id_categories !== null ? service.id_categories : '';
$category.val(categoryId); $category.val(categoryId);