UNPKG

@ia2coop/ia2-annotation-tool

Version:
113 lines (104 loc) 4.51 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.selectAnonymizer = exports.default = exports.clearDeleteAnnotations = exports.clearNewAnnotations = exports.updateSelectTag = exports.removeNewAnnotations = exports.removeDeleteAnnotations = exports.updateDeleteAnnotations = exports.updateNewAnnotations = exports.updateTags = exports.updateAnalysisSuccess = exports.updateId = exports.updateAnnotations = exports.updateText = void 0; var _toolkit = require("@reduxjs/toolkit"); var _reduxUndo = _interopRequireDefault(require("redux-undo")); var anonymizerSlice = (0, _toolkit.createSlice)({ name: "anonymizer", initialState: { id: 0, text: "", annotations: [], newAnnotations: [], deleteAnnotations: [], selectTag: null, tags: [{ id: 3, name: "LOC", description: "Es una localización", should_anonimyzation: true }] }, reducers: { updateAnalysisSuccess: function updateAnalysisSuccess(state, action) { state.text = action.payload.text; state.annotations = action.payload.ents; state.id = action.payload.id; }, updateTags: function updateTags(state, action) { state.tags = action.payload; }, updateText: function updateText(state, action) { state.text = action.payload; }, updateId: function updateId(state, action) { state.id = action.payload; }, updateAnnotations: function updateAnnotations(state, action) { state.annotations = action.payload; }, updateNewAnnotations: function updateNewAnnotations(state, action) { state.newAnnotations = state.newAnnotations.concat(action.payload); }, updateDeleteAnnotations: function updateDeleteAnnotations(state, action) { state.deleteAnnotations = state.deleteAnnotations.concat(action.payload); }, removeNewAnnotations: function removeNewAnnotations(state, action) { state.newAnnotations = state.newAnnotations.filter( // Only necessary check start function (item) { return item.start !== action.payload.start; }); }, removeDeleteAnnotations: function removeDeleteAnnotations(state, action) { state.deleteAnnotations = state.deleteAnnotations.filter( // Only necessary check start function (item) { return item.start !== action.payload.start; }); }, updateSelectTag: function updateSelectTag(state, action) { state.selectTag = state.tags.find(function (tag) { return tag.name === action.payload; }); }, clearNewAnnotations: function clearNewAnnotations(state) { state.newAnnotations = []; }, clearDeleteAnnotations: function clearDeleteAnnotations(state) { state.deleteAnnotations = []; } } }); var _anonymizerSlice$acti = anonymizerSlice.actions, updateText = _anonymizerSlice$acti.updateText, updateAnnotations = _anonymizerSlice$acti.updateAnnotations, updateId = _anonymizerSlice$acti.updateId, updateAnalysisSuccess = _anonymizerSlice$acti.updateAnalysisSuccess, updateTags = _anonymizerSlice$acti.updateTags, updateNewAnnotations = _anonymizerSlice$acti.updateNewAnnotations, updateDeleteAnnotations = _anonymizerSlice$acti.updateDeleteAnnotations, removeDeleteAnnotations = _anonymizerSlice$acti.removeDeleteAnnotations, removeNewAnnotations = _anonymizerSlice$acti.removeNewAnnotations, updateSelectTag = _anonymizerSlice$acti.updateSelectTag, clearNewAnnotations = _anonymizerSlice$acti.clearNewAnnotations, clearDeleteAnnotations = _anonymizerSlice$acti.clearDeleteAnnotations; exports.clearDeleteAnnotations = clearDeleteAnnotations; exports.clearNewAnnotations = clearNewAnnotations; exports.updateSelectTag = updateSelectTag; exports.removeNewAnnotations = removeNewAnnotations; exports.removeDeleteAnnotations = removeDeleteAnnotations; exports.updateDeleteAnnotations = updateDeleteAnnotations; exports.updateNewAnnotations = updateNewAnnotations; exports.updateTags = updateTags; exports.updateAnalysisSuccess = updateAnalysisSuccess; exports.updateId = updateId; exports.updateAnnotations = updateAnnotations; exports.updateText = updateText; var _default = (0, _reduxUndo.default)(anonymizerSlice.reducer); exports.default = _default; var selectAnonymizer = function selectAnonymizer(state) { return state.anonymizer; }; exports.selectAnonymizer = selectAnonymizer;