mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
update place api and admin ui
This commit is contained in:
parent
f3dab2d315
commit
c4940eaf12
4 changed files with 29 additions and 3 deletions
|
@ -22,6 +22,7 @@ api.route('/user')
|
|||
|
||||
api.get('/users', isAuth, isAdmin, userController.getAll)
|
||||
api.put('/tag', isAuth, isAdmin, eventController.updateTag)
|
||||
api.put('/place', isAuth, isAdmin, eventController.updatePlace)
|
||||
|
||||
api.route('/user/event')
|
||||
.post(isAuth, upload.single('image'), userController.addEvent)
|
||||
|
|
|
@ -32,7 +32,12 @@ const eventController = {
|
|||
res.send(404)
|
||||
}
|
||||
},
|
||||
|
||||
async updatePlace (req, res) {
|
||||
const place = await Place.findByPk(req.body.id)
|
||||
console.log(place)
|
||||
await place.update(req.body)
|
||||
res.json(place)
|
||||
},
|
||||
async get (req, res) {
|
||||
const id = req.params.event_id
|
||||
const event = await Event.findByPk(id, { include: [User, Tag, Comment, Place] })
|
||||
|
|
|
@ -33,6 +33,7 @@ export default {
|
|||
getAllEvents: (month, year) => get(`/event/${year}/${month}/`),
|
||||
addEvent: event => post('/user/event', event),
|
||||
updateEvent: event => put('/user/event', event),
|
||||
updatePlace: place => put('/place', place),
|
||||
delEvent: eventId => del(`/user/event/${eventId}`),
|
||||
getEvent: eventId => get(`/event/${eventId}`),
|
||||
getMeta: () => get('/event/meta'),
|
||||
|
|
|
@ -15,8 +15,17 @@
|
|||
template(slot='title')
|
||||
v-icon(name='map-marker-alt')
|
||||
span {{$t('Places')}}
|
||||
b-table(:items='places' :fields='placeFields' striped hover)
|
||||
b-tab
|
||||
p You can change place's name or address
|
||||
b-form.mb-2(inline)
|
||||
b-input.mr-1(:placeholder='$t("Name")' v-model='place.name')
|
||||
b-input.mr-1(:placeholder='$t("Address")' v-model='place.address')
|
||||
b-button(variant='primary' @click='savePlace') {{$t('Save')}}
|
||||
b-table(selectable :items='places' :fields='placeFields' striped hover
|
||||
small selectedVariant='success' primary-key='id'
|
||||
select-mode="single" @row-selected='placeSelected'
|
||||
:per-page='5' :current-page='placePage')
|
||||
b-pagination(:per-page='5' v-model='placePage' :total-rows='places.length')
|
||||
b-tab.pt-1
|
||||
template(slot='title')
|
||||
v-icon(name='tag')
|
||||
span {{$t('Tags')}}
|
||||
|
@ -51,6 +60,16 @@ export default {
|
|||
},
|
||||
computed: mapState(['tags', 'places']),
|
||||
methods: {
|
||||
placeSelected (items) {
|
||||
const item = items[0]
|
||||
this.place.name = item.name
|
||||
this.place.address = item.address
|
||||
this.place.id = item.id
|
||||
},
|
||||
async savePlace () {
|
||||
const place = await api.updatePlace(this.place)
|
||||
|
||||
},
|
||||
async toggle(user) {
|
||||
user.is_active = !user.is_active
|
||||
const newuser = await api.updateUser(user)
|
||||
|
|
Loading…
Reference in a new issue