Punk-Queue

 view release on metacpan or  search on metacpan

lib/Punk/Plugin/Queue/assets/funky/js/35-table.js  view on Meta::CPAN

	 * Set advanced filter parameters programmatically
	 * @param {Object} params - Filter parameters
	 * @returns {TableInstance}
	 */
	TableInstance.prototype.setAdvancedFilters = function(params) {
		if (this._advancedFilter && this._advancedFilter.loadFromParams) {
			this._advancedFilter.loadFromParams(params);
		} else {
			this._applyAdvancedFilters(params);
		}
		return this;
	};

	/**
	 * Clear all advanced filters
	 * @returns {TableInstance}
	 */
	TableInstance.prototype.clearAdvancedFilters = function() {
		if (this._advancedFilter) {
			this._advancedFilter.clearFilters();
		}
		this._clearAdvancedFilters();
		return this;
	};

	/**
	 * Save current filters as template
	 * @param {string} name - Template name
	 * @returns {Promise}
	 */
	TableInstance.prototype.saveFilterTemplate = function(name) {
		if (this._advancedFilter && this._advancedFilter.saveFilter) {
			return this._advancedFilter.saveFilter(name);
		}
		return Promise.reject(new Error('AdvancedFilter not initialized'));
	};

	/**
	 * Load filter template by name
	 * @param {string} name - Template name
	 * @returns {Promise}
	 */
	TableInstance.prototype.loadFilterTemplate = function(name) {
		if (this._advancedFilter && this._advancedFilter.loadSavedFilter) {
			return this._advancedFilter.loadSavedFilter(name);
		}
		return Promise.reject(new Error('AdvancedFilter not initialized'));
	};

	/**
	 * Get shareable filter URL
	 * @returns {string}
	 */
	TableInstance.prototype.getFilterUrl = function() {
		var params = this.getAdvancedFilters();
		var encoded = btoa(JSON.stringify(params));
		return window.location.origin + window.location.pathname + '#filter=' + encoded;
	};

	/**
	 * Copy filter URL to clipboard
	 * @returns {Promise}
	 */
	TableInstance.prototype.copyFilterUrl = function() {
		var url = this.getFilterUrl();
		var self = this;

		if (navigator.clipboard && navigator.clipboard.writeText) {
			return navigator.clipboard.writeText(url).then(function() {
				if (Funky.Announce) {
					Funky.Announce.success('Filter URL copied to clipboard');
				}
				self._emit('filterUrlCopied', { url: url });
			});
		}

		// Fallback for older browsers
		var textarea = document.createElement('textarea');
		textarea.value = url;
		textarea.style.position = 'fixed';
		textarea.style.opacity = '0';
		document.body.appendChild(textarea);
		textarea.select();
		try {
			document.execCommand('copy');
			if (Funky.Announce) {
				Funky.Announce.success('Filter URL copied to clipboard');
			}
			this._emit('filterUrlCopied', { url: url });
		} catch (e) {
			console.warn('[Funky.Table] Failed to copy URL:', e);
		}
		document.body.removeChild(textarea);
		return Promise.resolve();
	};

	// =========================================================================
	// Public API - Column Profile Methods (Phase 12)
	// =========================================================================

	/**
	 * Get all column profiles
	 * @returns {Array}
	 */
	TableInstance.prototype.getProfiles = function() {
		return this._columnProfiles ? this._columnProfiles.profiles.slice() : [];
	};

	/**
	 * Get active profile
	 * @returns {Object|null}
	 */
	TableInstance.prototype.getActiveProfile = function() {
		return this._columnProfiles ? this._columnProfiles.activeProfile : null;
	};

	/**
	 * Apply profile by name
	 * @param {string} profileName - Profile name
	 * @returns {TableInstance}
	 */
	TableInstance.prototype.applyProfile = function(profileName) {
		this._applyProfileByName(profileName);
		return this;
	};

	/**
	 * Save current column state as profile
	 * @param {string} name - Profile name
	 * @param {string} [description] - Profile description
	 * @returns {TableInstance}
	 */
	TableInstance.prototype.saveProfile = function(name, description) {
		var self = this;

		var visibleColumns = this.config.columns
			.filter(function(col) { return self._isColumnVisible(col.data); })
			.map(function(col) { return col.data; });

		this._addProfile({
			name: name,
			description: description || '',
			columns: visibleColumns,
			columnWidths: this._getColumnWidths(),
			columnOrder: this._getColumnOrder()
		});



( run in 2.060 seconds using v1.01-cache-2.11-cpan-84e82930d8c )