All files / ext.wikilambda.edit/store/modules zTypedList.js

100% Statements 7/7
100% Branches 0/0
100% Functions 6/6
100% Lines 7/7

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 50              16x           1x     13x         1x     1x                         1x               1x        
/*!
 * WikiLambda Vue editor: zTypedLists Vuex module
 *
 * @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' );
		}
	}
};