Skip to content
Snippets Groups Projects
fileAjax.js 1.35 KiB
Newer Older
'use strict';

import $ from 'jquery';

/**
 * Ajax file operations
 */
export default class FileAjax {

	/**
	 * Kicks things off
	 */
	constructor() {
		$('.remove-file').on('click', this._removeFile);
		$('#sgjobs-joblist').delegate('.sgjobs-select', 'change', this._filterJoblist);
	}

	/**
	 * Remove file from application logic
	 *
	 * @param event
	 * @private
	 */
	_removeFile(event) {
		let currentElement = $(this);
		event.preventDefault();

		$.post(
			'?eID=sgAjax&extensionName=SgJobs&controller=Ajax%5CJoblist&action=deleteTempFile&format=json&vendorName=SGalinski',
			{
				file: currentElement.parent().children('.filename').html(),
				type: currentElement.attr('filetype')
			}
		).done(function() {
			currentElement.parent().remove();
		});
	 * Filter for the joblist
	 *
	 * @private
	 */
	_filterJoblist() {
		$.post(
			'?eID=sgAjax&extensionName=SgJobs&controller=Ajax%5CJoblist&action=filter&format=html',
			{
				recordPageId: $('#recordPageId').val(),
				parameters: {
					country: $('#filter-countries').val(),
					location: $('#filter-locations').val(),
					company: $('#filter-companies').val(),
					area: $('#filter-areas').val(),
					function: $('#filter-functions').val(),
				}
			}
		).done(function(result) {
			// replace filter & job list with result from ajax controller
			$('#sgjobs-joblist').html(result);
		});
	}