[balance] modify limit of one user in admin page
This commit is contained in:
		
							parent
							
								
									5e8f4bc86a
								
							
						
					
					
						commit
						57e468f1f4
					
				| 
						 | 
					@ -21,7 +21,28 @@
 | 
				
			||||||
            <q-td key="userid" :props="props">
 | 
					            <q-td key="userid" :props="props">
 | 
				
			||||||
              {{ getName(props.row.userid) }}
 | 
					              {{ getName(props.row.userid) }}
 | 
				
			||||||
            </q-td>
 | 
					            </q-td>
 | 
				
			||||||
            <q-td key="limit" :props="props"> {{ getLimit(props.row.userid) }}€ </q-td>
 | 
					            <q-td key="limit" :props="props">
 | 
				
			||||||
 | 
					              {{ getLimit(props.row.userid) }}€
 | 
				
			||||||
 | 
					              <q-popup-edit
 | 
				
			||||||
 | 
					                v-slot="scope"
 | 
				
			||||||
 | 
					                v-model="limit"
 | 
				
			||||||
 | 
					                buttons
 | 
				
			||||||
 | 
					                label-cancel="Abbrechen"
 | 
				
			||||||
 | 
					                label-set="Speichern"
 | 
				
			||||||
 | 
					                @save="setLimit(props.row.userid)"
 | 
				
			||||||
 | 
					                @cancel="limit = undefined"
 | 
				
			||||||
 | 
					              >
 | 
				
			||||||
 | 
					                <q-input
 | 
				
			||||||
 | 
					                  v-model.number="scope.value"
 | 
				
			||||||
 | 
					                  label="Limit"
 | 
				
			||||||
 | 
					                  type="number"
 | 
				
			||||||
 | 
					                  step="0.01"
 | 
				
			||||||
 | 
					                  suffix="€"
 | 
				
			||||||
 | 
					                  filled
 | 
				
			||||||
 | 
					                  dense
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					              </q-popup-edit>
 | 
				
			||||||
 | 
					            </q-td>
 | 
				
			||||||
            <q-td key="balance" :props="props">
 | 
					            <q-td key="balance" :props="props">
 | 
				
			||||||
              {{ getBalance(props.row.debit, props.row.credit) }}€
 | 
					              {{ getBalance(props.row.debit, props.row.credit) }}€
 | 
				
			||||||
              <q-menu anchor="bottom middle" self="top middle">
 | 
					              <q-menu anchor="bottom middle" self="top middle">
 | 
				
			||||||
| 
						 | 
					@ -148,6 +169,15 @@ export default defineComponent({
 | 
				
			||||||
      updateBalance(receiver);
 | 
					      updateBalance(receiver);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function setLimit(userid: string) {
 | 
				
			||||||
 | 
					      setTimeout(() => {
 | 
				
			||||||
 | 
					        void store.setLimit(<number>limit.value, userid);
 | 
				
			||||||
 | 
					      }, 50);
 | 
				
			||||||
 | 
					      setTimeout(() => {
 | 
				
			||||||
 | 
					        limit.value = undefined;
 | 
				
			||||||
 | 
					      }, 100);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const tab = ref('add');
 | 
					    const tab = ref('add');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
| 
						 | 
					@ -157,6 +187,7 @@ export default defineComponent({
 | 
				
			||||||
      setLimits: store.setLimits,
 | 
					      setLimits: store.setLimits,
 | 
				
			||||||
      getName,
 | 
					      getName,
 | 
				
			||||||
      getLimit,
 | 
					      getLimit,
 | 
				
			||||||
 | 
					      setLimit,
 | 
				
			||||||
      getBalance,
 | 
					      getBalance,
 | 
				
			||||||
      updateBalance,
 | 
					      updateBalance,
 | 
				
			||||||
      updateBalances,
 | 
					      updateBalances,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,5 +187,15 @@ export const useBalanceStore = defineStore({
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async setLimit(limit: number, userid: string) {
 | 
				
			||||||
 | 
					      await api.put(`users/${userid}/balance/limit`, { limit });
 | 
				
			||||||
 | 
					      const user_limit = this.user_limits.find((a) => a.userid === userid);
 | 
				
			||||||
 | 
					      if (user_limit) {
 | 
				
			||||||
 | 
					        user_limit.limit = limit;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.user_limits.push({ userid, limit });
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue