Integrated bootstrap tabs into the backend services page.

This commit is contained in:
alext 2017-09-22 14:53:41 +02:00
parent 80c6b61686
commit 861f49c259
2 changed files with 167 additions and 173 deletions

View file

@ -22,184 +22,185 @@
</script> </script>
<div id="services-page" class="container-fluid backend-page"> <div id="services-page" class="container-fluid backend-page">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="services-tab tab active"><a><?= lang('services') ?></a></li> <li role="presentation" class="active"><a href="#services" aria-controls="services" role="tab" data-toggle="tab"><?= lang('services') ?></a></li>
<li role="presentation" class="categories-tab tab"><a><?= lang('categories') ?></a></li> <li role="presentation"><a href="#categories" aria-controls="categories" role="tab" data-toggle="tab"><?= lang('categories') ?></a></li>
</ul> </ul>
<!-- SERVICES TAB --> <div class="tab-content">
<!-- SERVICES TAB -->
<div id="services" class="tab-content"> <div role="tabpanel" class="tab-pane active" id="services">
<?php // FILTER SERVICES ?> <div class="row">
<div class="row"> <div id="filter-services" class="filter-records column col-xs-12 col-sm-5">
<div id="filter-services" class="filter-records column col-xs-12 col-sm-5"> <form class="input-append">
<form class="input-append"> <input class="key" type="text" />
<input class="key" type="text" /> <div class="btn-group">
<div class="btn-group"> <button class="filter btn btn-default btn-sm" type="submit" title="<?= lang('filter') ?>">
<button class="filter btn btn-default btn-sm" type="submit" title="<?= lang('filter') ?>"> <span class="glyphglyphicon glyphicon glyphglyphicon glyphicon-search"></span>
<span class="glyphglyphicon glyphicon glyphglyphicon glyphicon-search"></span> </button>
</button> <button class="clear btn btn-default btn-sm" type="button" title="<?= lang('clear') ?>">
<button class="clear btn btn-default btn-sm" type="button" title="<?= lang('clear') ?>"> <span class="glyphglyphicon glyphicon glyphglyphicon glyphicon-repeat"></span>
<span class="glyphglyphicon glyphicon glyphglyphicon glyphicon-repeat"></span> </button>
</button> </div>
</div> </form>
</form>
<h3><?= lang('services') ?></h3> <h3><?= lang('services') ?></h3>
<div class="results"></div> <div class="results"></div>
</div> </div>
<div class="record-details column col-xs-12 col-sm-7"> <div class="record-details column col-xs-12 col-sm-7">
<div class="btn-toolbar"> <div class="btn-toolbar">
<div class="add-edit-delete-group btn-group"> <div class="add-edit-delete-group btn-group">
<button id="add-service" class="btn btn-primary"> <button id="add-service" class="btn btn-primary">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
<?= lang('add') ?> <?= lang('add') ?>
</button> </button>
<button id="edit-service" class="btn btn-default" disabled="disabled"> <button id="edit-service" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
<?= lang('edit') ?> <?= lang('edit') ?>
</button> </button>
<button id="delete-service" class="btn btn-default" disabled="disabled"> <button id="delete-service" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-remove"></span> <span class="glyphicon glyphicon-remove"></span>
<?= lang('delete') ?> <?= lang('delete') ?>
</button> </button>
</div>
<div class="save-cancel-group btn-group" style="display:none;">
<button id="save-service" class="btn btn-primary">
<span class="glyphicon glyphicon-ok"></span>
<?= lang('save') ?>
</button>
<button id="cancel-service" class="btn btn-default">
<span class="glyphicon glyphicon-ban-circle"></span>
<?= lang('cancel') ?>
</button>
</div>
</div> </div>
<div class="save-cancel-group btn-group" style="display:none;"> <h3><?= lang('details') ?></h3>
<button id="save-service" class="btn btn-primary"> <div class="form-message alert" style="display:none;"></div>
<span class="glyphicon glyphicon-ok"></span>
<?= lang('save') ?> <input type="hidden" id="service-id" />
</button>
<button id="cancel-service" class="btn btn-default"> <div class="form-group">
<span class="glyphicon glyphicon-ban-circle"></span> <label for="service-name"><?= lang('name') ?> *</label>
<?= lang('cancel') ?> <input type="text" id="service-name" class="form-control required" />
</button>
</div> </div>
<div class="form-group">
<label for="service-duration"><?= lang('duration_minutes') ?> *</label>
<input type="text" id="service-duration" class="form-control required" />
</div>
<div class="form-group">
<label for="service-price"><?= lang('price') ?> *</label>
<input type="text" id="service-price" class="form-control required" />
</div>
<div class="form-group">
<label for="service-currency"><?= lang('currency') ?></label>
<input type="text" id="service-currency" class="form-control" />
</div>
<div class="form-group">
<label for="service-category"><?= lang('category') ?></label>
<select id="service-category" class="form-control"></select>
</div>
<div class="form-group">
<label for="service-availabilities-type"><?= lang('availabilities_type') ?></label>
<select id="service-availabilities-type" class="form-control">
<option value="<?= AVAILABILITIES_TYPE_FLEXIBLE ?>">
<?= lang('flexible') ?>
</option>
<option value="<?= AVAILABILITIES_TYPE_FIXED ?>">
<?= lang('fixed') ?>
</option>
</select>
</div>
<div class="form-group">
<label for="service-attendants-number"><?= lang('attendants_number') ?> *</label>
<input type="text" id="service-attendants-number" class="form-control required" />
</div>
<div class="form-group">
<label for="service-description"><?= lang('description') ?></label>
<textarea id="service-description" rows="4" class="form-control"></textarea>
</div>
<p id="form-message" class="text-danger">
<em><?= lang('fields_are_required') ?></em>
</p>
</div> </div>
<h3><?= lang('details') ?></h3>
<div class="form-message alert" style="display:none;"></div>
<input type="hidden" id="service-id" />
<div class="form-group">
<label for="service-name"><?= lang('name') ?> *</label>
<input type="text" id="service-name" class="form-control required" />
</div>
<div class="form-group">
<label for="service-duration"><?= lang('duration_minutes') ?> *</label>
<input type="text" id="service-duration" class="form-control required" />
</div>
<div class="form-group">
<label for="service-price"><?= lang('price') ?> *</label>
<input type="text" id="service-price" class="form-control required" />
</div>
<div class="form-group">
<label for="service-currency"><?= lang('currency') ?></label>
<input type="text" id="service-currency" class="form-control" />
</div>
<div class="form-group">
<label for="service-category"><?= lang('category') ?></label>
<select id="service-category" class="form-control"></select>
</div>
<div class="form-group">
<label for="service-availabilities-type"><?= lang('availabilities_type') ?></label>
<select id="service-availabilities-type" class="form-control">
<option value="<?= AVAILABILITIES_TYPE_FLEXIBLE ?>">
<?= lang('flexible') ?>
</option>
<option value="<?= AVAILABILITIES_TYPE_FIXED ?>">
<?= lang('fixed') ?>
</option>
</select>
</div>
<div class="form-group">
<label for="service-attendants-number"><?= lang('attendants_number') ?> *</label>
<input type="text" id="service-attendants-number" class="form-control required" />
</div>
<div class="form-group">
<label for="service-description"><?= lang('description') ?></label>
<textarea id="service-description" rows="4" class="form-control"></textarea>
</div>
<p id="form-message" class="text-danger">
<em><?= lang('fields_are_required') ?></em>
</p>
</div> </div>
</div> </div>
</div>
<!-- CATEGORIES TAB --> <!-- CATEGORIES TAB -->
<div id="categories" class="tab-content" style="display:none;"> <div role="tabpanel" class="tab-pane" id="categories">
<div class="row"> <div class="row">
<div id="filter-categories" class="filter-records column col-xs-12 col-sm-5"> <div id="filter-categories" class="filter-records column col-xs-12 col-sm-5">
<form class="input-append"> <form class="input-append">
<input class="key" type="text" /> <input class="key" type="text" />
<div class="btn-group"> <div class="btn-group">
<button class="filter btn btn-default btn-sm" type="submit" title="<?= lang('filter') ?>"> <button class="filter btn btn-default btn-sm" type="submit" title="<?= lang('filter') ?>">
<span class="glyphicon glyphicon-search"></span> <span class="glyphicon glyphicon-search"></span>
</button> </button>
<button class="clear btn btn-default btn-sm" type="button" title="<?= lang('clear') ?>"> <button class="clear btn btn-default btn-sm" type="button" title="<?= lang('clear') ?>">
<span class="glyphicon glyphicon-repeat"></span> <span class="glyphicon glyphicon-repeat"></span>
</button> </button>
</div> </div>
</form> </form>
<h3><?= lang('categories') ?></h3> <h3><?= lang('categories') ?></h3>
<div class="results"></div> <div class="results"></div>
</div>
<div class="record-details col-xs-12 col-sm-7">
<div class="btn-toolbar">
<div class="add-edit-delete-group btn-group">
<button id="add-category" class="btn btn-primary">
<span class="glyphicon glyphicon-plus glyphicon glyphicon-white"></span>
<?= lang('add') ?>
</button>
<button id="edit-category" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-pencil"></span>
<?= lang('edit') ?>
</button>
<button id="delete-category" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-remove"></span>
<?= lang('delete') ?>
</button>
</div>
<div class="save-cancel-group btn-group" style="display:none;">
<button id="save-category" class="btn btn-primary">
<span class="glyphicon glyphicon-ok glyphicon glyphicon-white"></span>
<?= lang('save') ?>
</button>
<button id="cancel-category" class="btn btn-default">
<span class="glyphicon glyphicon-ban-circle"></span>
<?= lang('cancel') ?>
</button>
</div>
</div> </div>
<h3><?= lang('details') ?></h3> <div class="record-details col-xs-12 col-sm-7">
<div class="form-message alert" style="display:none;"></div> <div class="btn-toolbar">
<div class="add-edit-delete-group btn-group">
<button id="add-category" class="btn btn-primary">
<span class="glyphicon glyphicon-plus glyphicon glyphicon-white"></span>
<?= lang('add') ?>
</button>
<button id="edit-category" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-pencil"></span>
<?= lang('edit') ?>
</button>
<button id="delete-category" class="btn btn-default" disabled="disabled">
<span class="glyphicon glyphicon-remove"></span>
<?= lang('delete') ?>
</button>
</div>
<input type="hidden" id="category-id" /> <div class="save-cancel-group btn-group" style="display:none;">
<button id="save-category" class="btn btn-primary">
<span class="glyphicon glyphicon-ok glyphicon glyphicon-white"></span>
<?= lang('save') ?>
</button>
<button id="cancel-category" class="btn btn-default">
<span class="glyphicon glyphicon-ban-circle"></span>
<?= lang('cancel') ?>
</button>
</div>
</div>
<div class="form-group"> <h3><?= lang('details') ?></h3>
<label for="category-name"><?= lang('name') ?> *</label> <div class="form-message alert" style="display:none;"></div>
<input type="text" id="category-name" class="form-control required" />
</div>
<div class="form-group"> <input type="hidden" id="category-id" />
<label for="category-description"><?= lang('description') ?></label>
<textarea id="category-description" rows="4" class="form-control"></textarea> <div class="form-group">
<label for="category-name"><?= lang('name') ?> *</label>
<input type="text" id="category-name" class="form-control required" />
</div>
<div class="form-group">
<label for="category-description"><?= lang('description') ?></label>
<textarea id="category-description" rows="4" class="form-control"></textarea>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -76,16 +76,10 @@ window.BackendServices = window.BackendServices || {};
* *
* Changes the displayed tab. * Changes the displayed tab.
*/ */
$('.tab').click(function() { $('a[data-toggle="tab"]').on('shown.bs.tab', function() {
$(this).parent().find('.active').removeClass('active'); if ($(this).attr('href') === '#services') {
$(this).addClass('active');
$('.tab-content').hide();
if ($(this).hasClass('services-tab')) { // display services tab
$('#services').show();
helper = servicesHelper; helper = servicesHelper;
} else if ($(this).hasClass('categories-tab')) { // display categories tab } else if ($(this).attr('href') === '#categories') {
$('#categories').show();
helper = categoriesHelper; helper = categoriesHelper;
} }
@ -105,13 +99,13 @@ window.BackendServices = window.BackendServices || {};
* Use this method every time a change is made to the service categories db table. * Use this method every time a change is made to the service categories db table.
*/ */
exports.updateAvailableCategories = function() { exports.updateAvailableCategories = function() {
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories'; var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
key: '' key: ''
}; };
$.post(postUrl, postData, function(response) { $.post(url, data, function(response) {
if (!GeneralFunctions.handleAjaxExceptions(response)) { if (!GeneralFunctions.handleAjaxExceptions(response)) {
return; return;
} }
@ -125,6 +119,5 @@ window.BackendServices = window.BackendServices || {};
}); });
$select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null'); $select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
}, 'json').fail(GeneralFunctions.ajaxFailureHandler); }, 'json').fail(GeneralFunctions.ajaxFailureHandler);
} };
})(window.BackendServices); })(window.BackendServices);