Added better RS add and remove functionality.
This commit is contained in:
		
							parent
							
								
									f090e105dd
								
							
						
					
					
						commit
						f67be6e3ee
					
				| 
						 | 
					@ -59,8 +59,9 @@ export function removeRailSystem(rsStore, id) {
 | 
				
			||||||
            .then(() => {
 | 
					            .then(() => {
 | 
				
			||||||
                rsStore.selectedRailSystem = null;
 | 
					                rsStore.selectedRailSystem = null;
 | 
				
			||||||
                refreshRailSystems(rsStore)
 | 
					                refreshRailSystems(rsStore)
 | 
				
			||||||
                    .then(() => resolve)
 | 
					                    .then(resolve)
 | 
				
			||||||
                    .catch(error => reject(error));
 | 
					                    .catch(reject);
 | 
				
			||||||
            });
 | 
					            })
 | 
				
			||||||
 | 
					          .catch(reject);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,11 +6,16 @@
 | 
				
			||||||
    <q-item-section>
 | 
					    <q-item-section>
 | 
				
			||||||
      <q-item-label>{{railSystem.name}}</q-item-label>
 | 
					      <q-item-label>{{railSystem.name}}</q-item-label>
 | 
				
			||||||
    </q-item-section>
 | 
					    </q-item-section>
 | 
				
			||||||
 | 
					    <q-item-section top side>
 | 
				
			||||||
 | 
					      <q-btn size="12px" flat dense round icon="delete" @click.prevent="deleteRs"/>
 | 
				
			||||||
 | 
					    </q-item-section>
 | 
				
			||||||
  </q-item>
 | 
					  </q-item>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import { RailSystem } from "src/api/railSystems";
 | 
					import { RailSystem, removeRailSystem } from "src/api/railSystems";
 | 
				
			||||||
 | 
					import { useRailSystemsStore } from "stores/railSystemsStore";
 | 
				
			||||||
 | 
					import { useQuasar } from "quasar";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "RailSystemLink",
 | 
					  name: "RailSystemLink",
 | 
				
			||||||
| 
						 | 
					@ -19,6 +24,34 @@ export default {
 | 
				
			||||||
      type: RailSystem,
 | 
					      type: RailSystem,
 | 
				
			||||||
      required: true
 | 
					      required: true
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  setup() {
 | 
				
			||||||
 | 
					    const rsStore = useRailSystemsStore();
 | 
				
			||||||
 | 
					    const quasar = useQuasar();
 | 
				
			||||||
 | 
					    return {rsStore, quasar};
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    deleteRs() {
 | 
				
			||||||
 | 
					      this.quasar.dialog({
 | 
				
			||||||
 | 
					        title: "Confirm Removal",
 | 
				
			||||||
 | 
					        message: "Are you sure you want to remove this rail system? All associated data will be deleted, permanently.",
 | 
				
			||||||
 | 
					        cancel: true
 | 
				
			||||||
 | 
					      }).onOk(() => {
 | 
				
			||||||
 | 
					        removeRailSystem(this.rsStore, this.railSystem.id)
 | 
				
			||||||
 | 
					          .then(() => {
 | 
				
			||||||
 | 
					            this.quasar.notify({
 | 
				
			||||||
 | 
					              color: "positive",
 | 
				
			||||||
 | 
					              message: "Rail system removed."
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					          .catch(error => {
 | 
				
			||||||
 | 
					            this.quasar.notify({
 | 
				
			||||||
 | 
					              color: "negative",
 | 
				
			||||||
 | 
					              message: "An error occurred: " + error.response.data.message
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,14 +13,18 @@
 | 
				
			||||||
        dense
 | 
					        dense
 | 
				
			||||||
        type="text"
 | 
					        type="text"
 | 
				
			||||||
        label="Name"
 | 
					        label="Name"
 | 
				
			||||||
 | 
					        v-model="addRailSystemName"
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
      <q-btn label="Add" color="primary"></q-btn>
 | 
					      <q-btn label="Add" color="primary" @click="create"></q-btn>
 | 
				
			||||||
    </q-item>
 | 
					    </q-item>
 | 
				
			||||||
  </q-list>
 | 
					  </q-list>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import RailSystemLink from "components/RailSystemLink.vue";
 | 
					import RailSystemLink from "components/RailSystemLink.vue";
 | 
				
			||||||
 | 
					import { useRailSystemsStore } from "stores/railSystemsStore";
 | 
				
			||||||
 | 
					import { createRailSystem } from "src/api/railSystems";
 | 
				
			||||||
 | 
					import { useQuasar } from "quasar";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "RailSystemsList",
 | 
					  name: "RailSystemsList",
 | 
				
			||||||
| 
						 | 
					@ -30,6 +34,34 @@ export default {
 | 
				
			||||||
      type: Array,
 | 
					      type: Array,
 | 
				
			||||||
      required: true
 | 
					      required: true
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  setup() {
 | 
				
			||||||
 | 
					    const rsStore = useRailSystemsStore();
 | 
				
			||||||
 | 
					    const quasar = useQuasar();
 | 
				
			||||||
 | 
					    return {rsStore, quasar};
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  data() {
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					      addRailSystemName: ""
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    create() {
 | 
				
			||||||
 | 
					      createRailSystem(this.rsStore, this.addRailSystemName)
 | 
				
			||||||
 | 
					        .then(() => {
 | 
				
			||||||
 | 
					          this.addRailSystemName = "";
 | 
				
			||||||
 | 
					          this.quasar.notify({
 | 
				
			||||||
 | 
					            color: "positive",
 | 
				
			||||||
 | 
					            message: "Rail system created."
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        .catch(error => {
 | 
				
			||||||
 | 
					          this.quasar.notify({
 | 
				
			||||||
 | 
					            color: "negative",
 | 
				
			||||||
 | 
					            message: "An error occurred: " + error.response.data.message
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue