0
The back-end returns me a json with the records I need to show in the view. A "contract" can have more than one "demand" and when this occurs, it is repeated (in the database by another application) the registration of the contract modifying only the FK (foreign key) related to "demand". Ex.: contract X can be in demand 1,4,5 at the same time.
I use ng-repeat to show the contracts on the screen. There is a "demand" column where (by ng-class) the icon turns blue if the contract is in some demand.
Problem: As the database repeats the contract in several records changing only the demand field, these records also arrive repeated in the json. Is there any way to unify these repetitions in a single line and repeat only the demands of this contract? For example: the contract in json below is in demands 3,2 and 4. So I would like to show only once the contract and paint the 3 icons blue referring to the demands in which the same contract is related.
json (these 3 indexes below refer to the same contract, but with different demands):
4: SIG_UF: "SP"
VLR_CNTR: "30000.00"
idTipoDemanda: 3
numeroContrato: 30001
5: SIG_UF: "SP"
VLR_CNTR: "30000.00"
idTipoDemanda: 2
numeroContrato: 30001
6: SIG_UF: "SP"
VLR_CNTR: "30000.00"
idTipoDemanda: 4
numeroContrato: 30001
HTML of the icon:
<span class="inline-block">
<i ng-class="{'mi mi--fiber-manual-record tx-primary': contrato.idTipoDemanda==3, 'mi mi--fiber-manual-record tx-grey': contrato.idTipoDemanda!=3}"></i>
<i ng-class="{'mi mi--fiber-manual-record tx-primary': contrato.idTipoDemanda==8, 'mi mi--fiber-manual-record tx-grey': contrato.idTipoDemanda!=8}"></i>
<i ng-class="{'mi mi--fiber-manual-record tx-primary': contrato.idTipoDemanda==2, 'mi mi--fiber-manual-record tx-grey': contrato.idTipoDemanda!=2}"></i>
<i ng-class="{'mi mi--fiber-manual-record tx-primary': contrato.idTipoDemanda==4, 'mi mi--fiber-manual-record tx-grey': contrato.idTipoDemanda !=4}"></i>
<i ng-class="{'mi mi--fiber-manual-record tx-primary': contrato.idTipoDemanda==5, 'mi mi--fiber-manual-record tx-grey': contrato.idTipoDemanda!=5}"></i>
</span>
How icons are shown:
Thank you John Paul, solved the problem.
– Ênio Filho