| 1 |
export default { |
| 2 |
interrogatingCount (state) { |
| 3 |
if (!state.activeCase) { |
| 4 |
return 0 |
| 5 |
} |
| 6 |
if (!state.activeCase.suspects_under_interrogation) { |
| 7 |
return 0 |
| 8 |
} |
| 9 |
return state.activeCase.suspects_under_interrogation.length |
| 10 |
}, |
| 11 |
clearedCount (state) { |
| 12 |
if (!state.activeCase) { |
| 13 |
return 0 |
| 14 |
} |
| 15 |
if (!state.activeCase.cleared_suspects) { |
| 16 |
return 0 |
| 17 |
} |
| 18 |
return state.activeCase.cleared_suspects.length |
| 19 |
}, |
| 20 |
remainingCount (state, getters) { |
| 21 |
return getters.holdingCell.length |
| 22 |
}, |
| 23 |
notHolding (state) { |
| 24 |
if (!state.activeCase) { |
| 25 |
return [] |
| 26 |
} |
| 27 |
if (!state.activeCase.cleared_suspects) { |
| 28 |
return [] |
| 29 |
} |
| 30 |
if (!state.activeCase.suspects_under_interrogation) { |
| 31 |
return [] |
| 32 |
} |
| 33 |
return [...state.activeCase.cleared_suspects, ...state.activeCase.suspects_under_interrogation] |
| 34 |
}, |
| 35 |
holdingCell (state, getters) { |
| 36 |
if (!state.activeCase) { |
| 37 |
return [] |
| 38 |
} |
| 39 |
if (!state.activeCase.all_suspects) { |
| 40 |
return [] |
| 41 |
} |
| 42 |
return Object.keys(state.activeCase.all_suspects).filter((el) => { |
| 43 |
return getters.notHolding.indexOf(el) < 0 |
| 44 |
}) |
| 45 |
}, |
| 46 |
updatedApi (state) { |
| 47 |
if (typeof state.api === 'undefined') { |
| 48 |
return |
| 49 |
} |
| 50 |
|
| 51 |
let api = {} |
| 52 |
for (var prop in state.api) { |
| 53 |
if (state.api[prop] && typeof state.api[prop] === 'string' && state.api[prop].indexOf('http') > -1) { |
| 54 |
let url = document.createElement('a') |
| 55 |
url.setAttribute('href', state.api[prop]) |
| 56 |
api[prop] = state.api[prop].replace(url.protocol, state.requestProtocol) |
| 57 |
} else { |
| 58 |
api[prop] = state.api[prop] |
| 59 |
} |
| 60 |
} |
| 61 |
return api |
| 62 |
}, |
| 63 |
updatedActiveCase (state) { |
| 64 |
if (typeof state.activeCase === 'undefined') { |
| 65 |
return |
| 66 |
} |
| 67 |
|
| 68 |
let activeCase = {} |
| 69 |
for (var prop in state.activeCase) { |
| 70 |
if (state.activeCase[prop] && typeof state.activeCase[prop] === 'string' && state.activeCase[prop].indexOf('http') > -1) { |
| 71 |
let url = document.createElement('a') |
| 72 |
url.setAttribute('href', state.activeCase[prop]) |
| 73 |
activeCase[prop] = state.activeCase[prop].replace(url.protocol, state.requestProtocol) |
| 74 |
} else { |
| 75 |
activeCase[prop] = state.activeCase[prop] |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
return activeCase |
| 80 |
} |
| 81 |
} |
| 82 |
|