cspace-ui
Version:
CollectionSpace user interface for browsers
42 lines (41 loc) • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getVocabulary = exports.getRecordType = exports.getKeyword = exports.getAdvancedSearchTerms = exports.getAdvancedLimitBy = exports.getAdvanced = exports.default = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _actionCodes = require("../constants/actionCodes");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var _default = (state = _immutable.default.Map(), action) => {
switch (action.type) {
case _actionCodes.SET_SEARCH_TO_SELECT_ADVANCED:
return state.set('advanced', _immutable.default.fromJS(action.payload));
case _actionCodes.SET_SEARCH_TO_SELECT_ADVANCED_SEARCH_TERMS:
return state.set('advancedSearchTerms', _immutable.default.fromJS(action.payload));
case _actionCodes.SET_SEARCH_TO_SELECT_ADVANCED_LIMIT_BY:
return state.set('advancedLimitBy', _immutable.default.fromJS(action.payload));
case _actionCodes.SET_SEARCH_TO_SELECT_KEYWORD:
return state.set('keyword', action.payload);
case _actionCodes.SET_SEARCH_TO_SELECT_RECORD_TYPE:
return state.set('recordType', action.payload).delete('advanced').delete('advancedLimitBy').delete('advancedSearchTerms');
case _actionCodes.SET_SEARCH_TO_SELECT_VOCABULARY:
return state.setIn(['vocabulary', state.get('recordType')], action.payload);
case _actionCodes.CLEAR_SEARCH_TO_SELECT:
return state.delete('advanced').delete('advancedLimitBy').delete('advancedSearchTerms').delete('keyword');
default:
return state;
}
};
exports.default = _default;
const getAdvanced = state => state.get('advanced');
exports.getAdvanced = getAdvanced;
const getAdvancedLimitBy = state => state.get('advancedLimitBy');
exports.getAdvancedLimitBy = getAdvancedLimitBy;
const getAdvancedSearchTerms = state => state.get('advancedSearchTerms');
exports.getAdvancedSearchTerms = getAdvancedSearchTerms;
const getKeyword = state => state.get('keyword');
exports.getKeyword = getKeyword;
const getRecordType = state => state.get('recordType');
exports.getRecordType = getRecordType;
const getVocabulary = (state, recordType) => state.getIn(['vocabulary', recordType]);
exports.getVocabulary = getVocabulary;