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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 2x 2x 2x | /*! * WikiLambda Vuex code to manipulate the ZImplementations of a ZFunction object. * * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt * @license MIT */ var Constants = require( '../../Constants.js' ); function filterOutPresentZids( rootState ) { return function ( zid ) { var zobject; for ( zobject in rootState.zobjectModule.zobject ) { if ( rootState.zobjectModule.zobject[ zobject ].value === zid ) { return false; } } return true; }; } module.exports = exports = { state: { /** * List of implementation keys */ zImplementations: [] }, getters: { getZImplementations: function ( state ) { return state.zImplementations; }, getUnattachedZImplementations: function ( state, getters, rootState ) { return state.zImplementations.filter( filterOutPresentZids( rootState ) ); } }, mutations: { /** * Set the zImplementations in the store * * @param {Object} state * @param {Object} zImplementations */ setZImplementations: function ( state, zImplementations ) { state.zImplementations = zImplementations; } }, actions: { /** * Fetches function implementation of a the specified zFunctionId. * This methos will also fetch the zKeys in case of them are missing. * * @param {Object} context * @param {string} zFunctionId * * @return {Promise} */ fetchZImplementations: function ( context, zFunctionId ) { var api = new mw.Api(); return api.get( { action: 'query', list: 'wikilambdafn_search', format: 'json', // eslint-disable-next-line camelcase wikilambdafn_zfunction_id: zFunctionId, // eslint-disable-next-line camelcase wikilambdafn_type: Constants.Z_IMPLEMENTATION } ).then( function ( response ) { var zidList = response.query.wikilambdafn_search.map( function ( zidItem ) { return zidItem.zid; } ); context.commit( 'setZImplementations', zidList ); return context.dispatch( 'fetchZKeys', { zids: zidList } ); } ); } } }; |