All files / ext.wikilambda.app/store/modules listItems.js

100% Statements 49/49
100% Branches 8/8
100% Functions 7/7
100% Lines 49/49

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 507x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 7x 7x 9x 9x 7x 7x 7x 1x 7x 7x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 7x 7x 7x 7x 7x 7x 7x 1x 1x 7x 7x  
/*!
 * WikiLambda Vue editor: Handle item actions on the existing typed lists.
 *
 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
 * @license MIT
 */
 
module.exports = exports = {
	state: {
		invalidListItems: {}
	},
	getters: {
		getInvalidListItems: function ( state ) {
			return state.invalidListItems;
		},
		hasInvalidListItems: function ( state ) {
			return ( Object.keys( state.invalidListItems ).length > 0 );
		}
	},
	mutations: {
		setInvalidListItems: function ( state, payload ) {
			state.invalidListItems[ payload.parentRowId ] = payload.listItems;
		},
		clearInvalidListItems: function ( state ) {
			state.invalidListItems = {};
		}
	},
	actions: {
		/**
		 * Set items to remove for a particular list ID
		 *
		 * @param {Object} context
		 * @param {Object} payload
		 * @param {boolean} payload.parentRowId
		 * @param {boolean} payload.listItems
		 */
		setListItemsForRemoval: function ( context, payload ) {
			context.commit( 'setInvalidListItems', payload );
		},
		/**
		 * Clear the collection of list items to remove
		 *
		 * @param {Object} context
		 */
		clearListItemsForRemoval: function ( context ) {
			context.commit( 'clearInvalidListItems' );
		}
	}
};