Skip to content

Commit

Permalink
Add button for signing liability form
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcage committed Jun 16, 2022
1 parent 93219e2 commit 65e6335
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/Http/Controllers/Visitors/API/VisitorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public function checkin(Visitor $visitor, Request $request)
->json($this->getCheckedInData());
}

public function signLiabilityForm(Visitor $visitor)
{
$this->authorize('update', $visitor);

$visitor->liability_form_signed = true;
$visitor->save();

return new VisitorResource($visitor);
}

public function export()
{
$this->authorize('export-visitors');
Expand Down
4 changes: 4 additions & 0 deletions resources/js/api/visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default {
const url = route('api.visitors.checkin', visitorId)
return await api.post(url, data)
},
async signLiabilityForm (visitorId) {
const url = route('api.visitors.signLiabilityForm', visitorId)
return await api.post(url, {})
},
async dailyVisitors (params = {}) {
const url = route('api.visitors.dailyVisitors', params)
return await api.get(url)
Expand Down
17 changes: 17 additions & 0 deletions resources/js/components/visitors/VisitorDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@
</dt>
<dd class="col-sm-8">
<span class="text-danger"><font-awesome-icon icon="times"/> {{ $t('Not signed!') }}</span>
<b-button size="sm" @click="signLiabilityForm()" :disabled="isBusy">{{ $t('Mark as signed') }}</b-button>
</dd>
</template>
</dl>
</template>

<script>
import visitorsApi from "@/api/visitors";
import moment from "moment";
import { showSnackbar } from "@/utils";
export default {
props: {
value: {
Expand All @@ -71,6 +74,7 @@ export default {
data() {
return {
visitor: this.value,
isBusy: false,
};
},
computed: {
Expand All @@ -97,5 +101,18 @@ export default {
return null;
},
},
methods: {
async signLiabilityForm() {
this.isBusy = true;
try {
let data = await visitorsApi.signLiabilityForm(this.visitor.id);
this.visitor = data.data;
showSnackbar(this.$t("Visitor updated."));
} catch (err) {
alert(err);
}
this.isBusy = false;
}
}
};
</script>
1 change: 1 addition & 0 deletions resources/js/vue-i18n-locales.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ export default {
"Liability form": "Haftungsformular",
"Liability form signed": "Haftungsformular unterschrieben",
"Not signed!": "Nicht signiert!",
"Mark as signed": "Als signiert markieren",
"pagination": {
"previous": "&laquo; Zurück",
"next": "Weiter &raquo;"
Expand Down
2 changes: 1 addition & 1 deletion resources/js/ziggy.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -807,5 +807,6 @@
"Edit metadata": "Metadaten bearbeiten",
"Liability form": "Haftungsformular",
"Liability form signed": "Haftungsformular unterschrieben",
"Not signed!": "Nicht signiert!"
"Not signed!": "Nicht signiert!",
"Mark as signed": "Als signiert markieren"
}
3 changes: 3 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@

Route::post('{visitor}/checkins', [VisitorController::class, 'checkin'])
->name('checkin');

Route::post('{visitor}/signLiabilityForm', [VisitorController::class, 'signLiabilityForm'])
->name('signLiabilityForm');
});

//
Expand Down

0 comments on commit 65e6335

Please sign in to comment.