HEX
Server: Apache/2.4.65 (Debian)
System: Linux wordpress-7cb4c6b6f6-js66c 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: www-data (33)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/jet-engine/includes/components/taxonomies/assets/js/list.js
(function( $, JetEngineCPTListConfig ) {

	'use strict';

	window.JetEngineCPTList = new Vue( {
		el: '#jet_cpt_list',
		template: '#jet-cpt-list',
		data: {
			errorNotices: [],
			editLink: JetEngineCPTListConfig.edit_link,
			builtInTypes: JetEngineCPTListConfig.built_in_types,
			engineTypes: JetEngineCPTListConfig.engine_types,
			showDeleteDialog: false,
			showTypes: 'jet-engine',
			deletedItem: {},
		},
		computed: {
			slugsList: function() {
				var result = [];

				for ( var i = 0; i < this.itemsList.length; i++ ) {
					result.push( this.itemsList[i].slug );
				}

				return result;
			},
			itemsList: function() {
				var result = [];

				if ( 'jet-engine' === this.showTypes ) {
					result = this.engineTypes;
				} else {
					result = this.builtInTypes;
				}

				return result;
			},
		},
		methods: {
			switchType: function() {
				if ( 'jet-engine' === this.showTypes ) {
					this.showTypes = 'built-in';
				} else {
					this.showTypes = 'jet-engine';
				}
			},
			copyItem: function( item ) {

				if ( !item || !item.id ) {
					return;
				}

				var self = this;

				wp.apiFetch( {
					method: 'post',
					path: JetEngineCPTListConfig.api_path_copy + item.id,
				} ).then( function( response ) {

					if ( response.success && response.item ) {

						self.engineTypes.unshift( response.item );

						self.$CXNotice.add( {
							message: JetEngineCPTListConfig.notices.copied,
							type: 'success',
						} );

					} else {
						if ( response.notices.length ) {
							response.notices.forEach( function( notice ) {

								self.$CXNotice.add( {
									message: notice.message,
									type: 'error',
									duration: 7000,
								} );


							} );
						}
					}
				} ).catch( function( response ) {

					self.$CXNotice.add( {
						message: response.message,
						type: 'error',
						duration: 7000,
					} );

				} );
			},
			deleteItem: function( item ) {
				this.deletedItem      = item;
				this.showDeleteDialog = true;
			},
			getEditLink: function( id, slug ) {

				var editLink = this.editLink.replace( /%id%/, id );

				if ( 'built-in' === this.showTypes ) {
					editLink += '&edit-type=built-in&tax=' + slug;
				}

				return editLink;

			},
		}
	} );

})( jQuery, window.JetEngineCPTListConfig );