easyappointments/assets/js/backend_users_providers.js

611 lines
24 KiB
JavaScript
Raw Normal View History

2015-07-20 22:41:24 +03:00
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
2015-07-20 22:41:24 +03:00
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
2015-07-20 22:41:24 +03:00
* @link http://easyappointments.org
* @since v1.0.0
* ---------------------------------------------------------------------------- */
2018-01-23 12:08:37 +03:00
(function () {
2016-04-26 22:33:30 +03:00
'use strict';
/**
2016-04-26 22:33:30 +03:00
* Providers Helper
*
* This class contains the Providers helper class declaration, along with the "Providers" tab
2016-10-06 22:10:56 +03:00
* event handlers. By dividing the backend/users tab functionality into separate files
2016-04-26 22:33:30 +03:00
* it is easier to maintain the code.
*
2016-04-26 22:33:30 +03:00
* @class ProvidersHelper
*/
2018-01-23 12:08:37 +03:00
var ProvidersHelper = function () {
2016-04-26 22:33:30 +03:00
this.filterResults = {}; // Store the results for later use.
this.filterLimit = 20;
2016-04-26 22:33:30 +03:00
};
/**
2016-04-26 22:33:30 +03:00
* Bind the event handlers for the backend/users "Providers" tab.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.bindEventHandlers = function () {
2016-04-26 22:33:30 +03:00
/**
* Event: Filter Providers Form "Submit"
*
* Filter the provider records with the given key string.
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('submit', '#filter-providers form', function () {
2016-04-26 22:33:30 +03:00
var key = $('#filter-providers .key').val();
$('.selected').removeClass('selected');
2016-04-26 22:33:30 +03:00
this.resetForm();
this.filter(key);
return false;
}.bind(this));
/**
* Event: Clear Filter Button "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#filter-providers .clear', function () {
2016-04-26 22:33:30 +03:00
this.filter('');
$('#filter-providers .key').val('');
this.resetForm();
}.bind(this));
/**
* Event: Filter Provider Row "Click"
*
* Display the selected provider data to the user.
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '.provider-row', function (e) {
2016-04-26 22:33:30 +03:00
if ($('#filter-providers .filter').prop('disabled')) {
$('#filter-providers .results').css('color', '#AAA');
return; // Exit because we are currently on edit mode.
}
2016-07-15 21:52:21 +03:00
var providerId = $(e.currentTarget).attr('data-id');
var provider = {};
2018-01-23 12:08:37 +03:00
$.each(this.filterResults, function (index, item) {
2016-04-26 22:33:30 +03:00
if (item.id === providerId) {
provider = item;
return false;
}
});
this.display(provider);
$('#filter-providers .selected').removeClass('selected');
$(e.currentTarget).addClass('selected');
2016-04-26 22:33:30 +03:00
$('#edit-provider, #delete-provider').prop('disabled', false);
}.bind(this));
/**
* Event: Add New Provider Button "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#add-provider', function () {
2016-04-26 22:33:30 +03:00
this.resetForm();
$('#filter-providers button').prop('disabled', true);
$('#filter-providers .results').css('color', '#AAA');
2016-04-26 22:33:30 +03:00
$('#providers .add-edit-delete-group').hide();
$('#providers .save-cancel-group').show();
$('#providers .record-details').find('input, textarea').prop('readonly', false);
$('#providers .record-details').find('select').prop('disabled', false);
2016-04-26 22:33:30 +03:00
$('#provider-password, #provider-password-confirm').addClass('required');
$('#provider-notifications').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
$('#provider-services input:checkbox').prop('disabled', false);
2016-04-26 22:33:30 +03:00
// Apply default working plan
BackendUsers.wp.setup(GlobalVariables.workingPlan);
BackendUsers.wp.timepickers(false);
}.bind(this));
/**
* Event: Edit Provider Button "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#edit-provider', function () {
2016-04-26 22:33:30 +03:00
$('#providers .add-edit-delete-group').hide();
$('#providers .save-cancel-group').show();
$('#filter-providers button').prop('disabled', true);
$('#filter-providers .results').css('color', '#AAA');
$('#providers .record-details').find('input, textarea').prop('readonly', false);
$('#providers .record-details').find('select').prop('disabled', false);
2016-04-26 22:33:30 +03:00
$('#provider-password, #provider-password-confirm').removeClass('required');
$('#provider-notifications').prop('disabled', false);
$('#provider-services input:checkbox').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
$('#providers input:checkbox').prop('disabled', false);
2016-04-26 22:33:30 +03:00
BackendUsers.wp.timepickers(false);
});
2016-04-26 22:33:30 +03:00
/**
* Event: Delete Provider Button "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#delete-provider', function () {
2016-04-26 22:33:30 +03:00
var providerId = $('#provider-id').val();
var buttons = [
{
text: EALang.delete,
2018-01-23 12:08:37 +03:00
click: function () {
this.delete(providerId);
$('#message_box').dialog('close');
}.bind(this)
},
{
text: EALang.cancel,
2018-01-23 12:08:37 +03:00
click: function () {
$('#message_box').dialog('close');
}
}
];
2016-04-26 22:33:30 +03:00
GeneralFunctions.displayMessageBox(EALang.delete_provider,
2018-01-23 12:08:37 +03:00
EALang.delete_record_prompt, buttons);
2016-04-26 22:33:30 +03:00
}.bind(this));
/**
* Event: Save Provider Button "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#save-provider', function () {
2016-04-26 22:33:30 +03:00
var provider = {
first_name: $('#provider-first-name').val(),
last_name: $('#provider-last-name').val(),
email: $('#provider-email').val(),
mobile_number: $('#provider-mobile-number').val(),
phone_number: $('#provider-phone-number').val(),
address: $('#provider-address').val(),
city: $('#provider-city').val(),
state: $('#provider-state').val(),
zip_code: $('#provider-zip-code').val(),
notes: $('#provider-notes').val(),
timezone: $('#provider-timezone').val(),
2016-04-26 22:33:30 +03:00
settings: {
username: $('#provider-username').val(),
working_plan: JSON.stringify(BackendUsers.wp.get()),
extra_working_plan: JSON.stringify(BackendUsers.wp.getExtraWP()),
notifications: $('#provider-notifications').hasClass('active'),
calendar_view: $('#provider-calendar-view').val()
2016-04-26 22:33:30 +03:00
}
};
// Include provider services.
provider.services = [];
2018-01-23 12:08:37 +03:00
$('#provider-services input:checkbox').each(function () {
2016-04-26 22:33:30 +03:00
if ($(this).prop('checked')) {
provider.services.push($(this).attr('data-id'));
}
});
// Include password if changed.
if ($('#provider-password').val() !== '') {
provider.settings.password = $('#provider-password').val();
}
2016-04-26 22:33:30 +03:00
// Include id if changed.
if ($('#provider-id').val() !== '') {
provider.id = $('#provider-id').val();
}
if (!this.validate()) {
2016-04-26 22:33:30 +03:00
return;
}
this.save(provider);
}.bind(this));
/**
* Event: Cancel Provider Button "Click"
*
* Cancel add or edit of an provider record.
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#cancel-provider', function () {
var id = $('#filter-providers .selected').attr('data-id');
2016-04-26 22:33:30 +03:00
this.resetForm();
if (id) {
2016-04-26 22:33:30 +03:00
this.select(id, true);
}
}.bind(this));
/**
* Event: Display Provider Details "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '.display-details', function () {
2016-04-26 22:33:30 +03:00
$('#providers .switch-view .current').removeClass('current');
$(this).addClass('current');
2018-01-23 12:08:37 +03:00
$('.working-plan-view').hide('fade', function () {
2016-04-26 22:33:30 +03:00
$('.details-view').show('fade');
});
});
2016-04-26 22:33:30 +03:00
/**
* Event: Display Provider Working Plan "Click"
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '.display-working-plan', function () {
2016-04-26 22:33:30 +03:00
$('#providers .switch-view .current').removeClass('current');
$(this).addClass('current');
2018-01-23 12:08:37 +03:00
$('.details-view').hide('fade', function () {
2016-04-26 22:33:30 +03:00
$('.working-plan-view').show('fade');
});
});
2016-04-26 22:33:30 +03:00
/**
* Event: Reset Working Plan Button "Click".
*/
2018-01-23 12:08:37 +03:00
$('#providers').on('click', '#reset-working-plan', function () {
$('.breaks tbody').empty();
$('.extra-periods tbody').empty();
2016-04-26 22:33:30 +03:00
$('.work-start, .work-end').val('');
BackendUsers.wp.setup(GlobalVariables.workingPlan);
BackendUsers.wp.timepickers(false);
});
};
/**
2016-04-26 22:33:30 +03:00
* Save provider record to database.
*
* @param {Object} provider Contains the admin record data. If an 'id' value is provided
2016-04-26 22:33:30 +03:00
* then the update operation is going to be executed.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.save = function (provider) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_provider';
var data = {
2016-07-15 21:52:21 +03:00
csrfToken: GlobalVariables.csrfToken,
provider: JSON.stringify(provider)
};
2016-04-26 22:33:30 +03:00
$.post(url, data)
.done(function (response) {
Backend.displayNotification(EALang.provider_saved);
this.resetForm();
$('#filter-providers .key').val('');
this.filter('', response.id, true);
}.bind(this))
.fail(GeneralFunctions.ajaxFailureHandler);
2016-04-26 22:33:30 +03:00
};
/**
2016-04-26 22:33:30 +03:00
* Delete a provider record from database.
*
* @param {Number} id Record id to be deleted.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.delete = function (id) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_provider';
var data = {
2016-07-15 21:52:21 +03:00
csrfToken: GlobalVariables.csrfToken,
provider_id: id
};
2016-04-26 22:33:30 +03:00
$.post(url, data)
.done(function () {
Backend.displayNotification(EALang.provider_deleted);
this.resetForm();
this.filter($('#filter-providers .key').val());
}.bind(this))
.fail(GeneralFunctions.ajaxFailureHandler);
2016-04-26 22:33:30 +03:00
};
/**
2016-04-26 22:33:30 +03:00
* Validates a provider record.
*
* @return {Boolean} Returns the validation result.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.validate = function () {
$('#providers .has-error').removeClass('has-error');
2016-04-26 22:33:30 +03:00
try {
// Validate required fields.
var missingRequired = false;
2018-01-23 12:08:37 +03:00
$('#providers .required').each(function () {
if (!$(this).val()) {
$(this).closest('.form-group').addClass('has-error');
2016-04-26 22:33:30 +03:00
missingRequired = true;
}
});
if (missingRequired) {
throw new Error(EALang.fields_are_required);
}
2016-04-26 22:33:30 +03:00
// Validate passwords.
if ($('#provider-password').val() !== $('#provider-password-confirm').val()) {
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
throw new Error(EALang.passwords_mismatch);
}
2016-04-26 22:33:30 +03:00
if ($('#provider-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
&& $('#provider-password').val() !== '') {
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
throw new Error(EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH));
2016-04-26 22:33:30 +03:00
}
// Validate user email.
if (!GeneralFunctions.validateEmail($('#provider-email').val())) {
$('#provider-email').closest('.form-group').addClass('has-error');
throw new Error(EALang.invalid_email);
2016-04-26 22:33:30 +03:00
}
2016-04-26 22:33:30 +03:00
// Check if username exists
if ($('#provider-username').attr('already-exists') === 'true') {
$('#provider-username').closest('.form-group').addClass('has-error');
throw new Error(EALang.username_already_exists);
2016-04-26 22:33:30 +03:00
}
return true;
} catch (error) {
$('#providers .form-message')
.addClass('alert-danger')
.text(error.message)
.show();
2016-04-26 22:33:30 +03:00
return false;
}
2016-04-26 22:33:30 +03:00
};
2016-04-26 22:33:30 +03:00
/**
* Resets the admin tab form back to its initial state.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.resetForm = function () {
$('#filter-providers .selected').removeClass('selected');
2016-04-26 22:33:30 +03:00
$('#filter-providers button').prop('disabled', false);
$('#filter-providers .results').css('color', '');
2016-04-26 22:33:30 +03:00
$('#providers .add-edit-delete-group').show();
$('#providers .save-cancel-group').hide();
$('#providers .record-details h3 a').remove();
$('#providers .record-details').find('input, textarea').prop('readonly', true);
$('#providers .record-details').find('select').prop('disabled', true);
2016-04-26 22:33:30 +03:00
$('#providers .form-message').hide();
$('#provider-notifications').removeClass('active');
$('#provider-notifications').prop('disabled', true);
$('#provider-services input:checkbox').prop('disabled', true);
$('#providers .add-break, .add-extra-periods, #reset-working-plan').prop('disabled', true);
2016-04-26 22:33:30 +03:00
BackendUsers.wp.timepickers(true);
$('#providers .working-plan input:text').timepicker('destroy');
$('#providers .working-plan input:checkbox').prop('disabled', true);
2016-04-26 22:33:30 +03:00
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
2016-04-26 22:33:30 +03:00
$('#edit-provider, #delete-provider').prop('disabled', true);
$('#providers .record-details').find('input, textarea').val('');
$('#provider-services input:checkbox').prop('checked', false);
$('#provider-services a').remove();
$('#providers .working-plan tbody').empty();
2016-04-26 22:33:30 +03:00
$('#providers .breaks tbody').empty();
$('#providers .extra-periods tbody').empty();
2016-04-26 22:33:30 +03:00
};
/**
2016-04-26 22:33:30 +03:00
* Display a provider record into the admin form.
*
* @param {Object} provider Contains the provider record data.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.display = function (provider) {
2016-04-26 22:33:30 +03:00
$('#provider-id').val(provider.id);
$('#provider-first-name').val(provider.first_name);
$('#provider-last-name').val(provider.last_name);
$('#provider-email').val(provider.email);
$('#provider-mobile-number').val(provider.mobile_number);
$('#provider-phone-number').val(provider.phone_number);
$('#provider-address').val(provider.address);
$('#provider-city').val(provider.city);
$('#provider-state').val(provider.state);
$('#provider-zip-code').val(provider.zip_code);
$('#provider-notes').val(provider.notes);
$('#provider-timezone').val(provider.timezone);
2016-04-26 22:33:30 +03:00
$('#provider-username').val(provider.settings.username);
$('#provider-calendar-view').val(provider.settings.calendar_view);
if (provider.settings.notifications === '1') {
2016-04-26 22:33:30 +03:00
$('#provider-notifications').addClass('active');
} else {
$('#provider-notifications').removeClass('active');
}
// Add dedicated provider link.
2018-01-23 12:08:37 +03:00
var dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id);
var linkHtml = '<a href="' + dedicatedUrl + '"><span class="glyphicon glyphicon-link"></span></a>';
2016-10-06 22:10:56 +03:00
$('#providers .details-view h3')
.find('a')
.remove()
.end()
.append(linkHtml);
$('#provider-services a').remove();
$('#provider-services input:checkbox').prop('checked', false);
2018-01-23 12:08:37 +03:00
$.each(provider.services, function (index, serviceId) {
$('#provider-services input:checkbox').each(function () {
if (Number($(this).attr('data-id')) === Number(serviceId)) {
2016-04-26 22:33:30 +03:00
$(this).prop('checked', true);
// Add dedicated service-provider link.
2018-01-23 12:08:37 +03:00
dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id)
+ '&service=' + encodeURIComponent(serviceId);
linkHtml = '<a href="' + dedicatedUrl + '"><span class="glyphicon glyphicon-link"></span></a>';
$(this).parent().append(linkHtml);
2016-04-26 22:33:30 +03:00
}
});
});
2016-04-26 22:33:30 +03:00
// Display working plan
var workingPlan = $.parseJSON(provider.settings.working_plan);
BackendUsers.wp.setup(workingPlan);
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
$('#providers .extra-periods tbody').empty();
var extraWorkingPlan = $.parseJSON(provider.settings.extra_working_plan);
BackendUsers.wp.setupExtraPeriods(extraWorkingPlan);
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
$('#providers .working-plan input:checkbox').prop('disabled', true);
2016-04-26 22:33:30 +03:00
};
/**
2016-04-26 22:33:30 +03:00
* Filters provider records depending a string key.
*
* @param {string} key This is used to filter the provider records of the database.
* @param {numeric} selectId Optional, if set, when the function is complete a result row can be set as selected.
* @param {bool} display Optional (false), if true the selected record will be also displayed.
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.filter = function (key, selectId, display) {
2016-04-26 22:33:30 +03:00
display = display || false;
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
var data = {
2016-07-15 21:52:21 +03:00
csrfToken: GlobalVariables.csrfToken,
key: key,
limit: this.filterLimit
2016-07-15 21:52:21 +03:00
};
2016-04-26 22:33:30 +03:00
$.post(url, data)
.done(function (response) {
this.filterResults = response;
$('#filter-providers .results').html('');
$.each(response, function (index, provider) {
var html = this.getFilterHtml(provider);
$('#filter-providers .results').append(html);
}.bind(this));
if (!response.length) {
$('#filter-providers .results').html('<em>' + EALang.no_records_found + '</em>')
} else if (response.length === this.filterLimit) {
$('<button/>', {
'type': 'button',
'class': 'well btn-block load-more text-center',
'text': EALang.load_more,
'click': function () {
this.filterLimit += 20;
this.filter(key, selectId, display);
}.bind(this)
})
.appendTo('#filter-providers .results');
}
if (selectId) {
this.select(selectId, display);
}
}.bind(this))
.fail(GeneralFunctions.ajaxFailureHandler);
2016-04-26 22:33:30 +03:00
};
2016-04-26 22:33:30 +03:00
/**
* Get an provider row html code that is going to be displayed on the filter results list.
*
* @param {Object} provider Contains the provider record data.
*
* @return {String} The html code that represents the record on the filter results list.
2016-04-26 22:33:30 +03:00
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.getFilterHtml = function (provider) {
2016-04-26 22:33:30 +03:00
var name = provider.first_name + ' ' + provider.last_name,
2018-01-23 12:08:37 +03:00
info = provider.email;
info = provider.mobile_number ? info + ', ' + provider.mobile_number : info;
info = provider.phone_number ? info + ', ' + provider.phone_number : info;
2016-04-26 22:33:30 +03:00
var html =
2018-01-23 12:08:37 +03:00
'<div class="provider-row entry" data-id="' + provider.id + '">' +
'<strong>' + name + '</strong><br>' +
info + '<br>' +
'</div><hr>';
2016-04-26 22:33:30 +03:00
return html;
};
2016-04-26 22:33:30 +03:00
/**
* Initialize the editable functionality to the break day table cells.
*
* @param {Object} $selector The cells to be initialized.
2016-04-26 22:33:30 +03:00
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.editableBreakDay = function ($selector) {
2016-04-26 22:33:30 +03:00
var weekDays = {};
weekDays[EALang.monday] = 'Monday';
weekDays[EALang.tuesday] = 'Tuesday';
weekDays[EALang.wednesday] = 'Wednesday';
weekDays[EALang.thursday] = 'Thursday';
weekDays[EALang.friday] = 'Friday';
weekDays[EALang.saturday] = 'Saturday';
weekDays[EALang.sunday] = 'Sunday';
2016-04-26 22:33:30 +03:00
2018-01-23 12:08:37 +03:00
$selector.editable(function (value, settings) {
2016-04-26 22:33:30 +03:00
return value;
}, {
type: 'select',
data: weekDays,
event: 'edit',
height: '30px',
submit: '<button type="button" class="hidden submit-editable">Submit</button>',
cancel: '<button type="button" class="hidden cancel-editable">Cancel</button>',
onblur: 'ignore',
2018-01-23 12:08:37 +03:00
onreset: function (settings, td) {
2016-04-26 22:33:30 +03:00
if (!BackendUsers.enableCancel) {
return false; // disable ESC button
}
},
2018-01-23 12:08:37 +03:00
onsubmit: function (settings, td) {
2016-04-26 22:33:30 +03:00
if (!BackendUsers.enableSubmit) {
return false; // disable Enter button
}
}
});
2015-05-28 00:42:40 +03:00
};
2016-04-26 22:33:30 +03:00
/**
* Initialize the editable functionality to the break time table cells.
*
* @param {jQuery} $selector The cells to be initialized.
2016-04-26 22:33:30 +03:00
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.editableBreakTime = function ($selector) {
$selector.editable(function (value, settings) {
2016-04-26 22:33:30 +03:00
// Do not return the value because the user needs to press the "Save" button.
return value;
}, {
event: 'edit',
height: '25px',
submit: '<button type="button" class="hidden submit-editable">Submit</button>',
cancel: '<button type="button" class="hidden cancel-editable">Cancel</button>',
onblur: 'ignore',
2018-01-23 12:08:37 +03:00
onreset: function (settings, td) {
2016-04-26 22:33:30 +03:00
if (!BackendUsers.enableCancel) {
return false; // disable ESC button
}
},
2018-01-23 12:08:37 +03:00
onsubmit: function (settings, td) {
2016-04-26 22:33:30 +03:00
if (!BackendUsers.enableSubmit) {
return false; // disable Enter button
}
}
});
2016-04-26 22:33:30 +03:00
};
2016-04-26 22:33:30 +03:00
/**
* Select and display a providers filter result on the form.
*
* @param {Number} id Record id to be selected.
* @param {Boolean} display Optional (false), if true the record will be displayed on the form.
2016-04-26 22:33:30 +03:00
*/
2018-01-23 12:08:37 +03:00
ProvidersHelper.prototype.select = function (id, display) {
2016-04-26 22:33:30 +03:00
display = display || false;
2016-04-26 22:33:30 +03:00
// Select record in filter results.
2018-01-23 12:08:37 +03:00
$('#filter-providers .provider-row').each(function () {
if (Number($(this).attr('data-id')) === Number(id)) {
$(this).addClass('selected');
2016-04-26 22:33:30 +03:00
return false;
}
});
2016-04-26 22:33:30 +03:00
// Display record in form (if display = true).
if (display) {
2018-01-23 12:08:37 +03:00
$.each(this.filterResults, function (index, provider) {
if (Number(provider.id) === Number(id)) {
2016-04-26 22:33:30 +03:00
this.display(provider);
$('#edit-provider, #delete-provider').prop('disabled', false);
return false;
}
}.bind(this));
}
2016-04-26 22:33:30 +03:00
};
2016-04-26 22:33:30 +03:00
window.ProvidersHelper = ProvidersHelper;
2016-04-26 22:33:30 +03:00
})();