diff --git a/app/abilities/room-advert.js b/app/abilities/room-advert.js new file mode 100644 index 000000000..d54caeaf6 --- /dev/null +++ b/app/abilities/room-advert.js @@ -0,0 +1,31 @@ +import { isNone } from '@ember/utils'; +import { Ability } from 'ember-can'; + +export default class RoomAdvert extends Ability { + get canCreate() { + return this.session.hasPermission('room-advert.create'); + } + + get canShow() { + return this.session.hasPermission('room-advert.read'); + } + + get canDestroy() { + return ( + this.session.hasPermission('room-advert.destroy') || + this.isRoomAdvertOwner(this.model) + ); + } + + get canEdit() { + return ( + this.session.hasPermission('room-advert.update') || + this.isRoomAdvertOwner(this.model) + ); + } + + isRoomAdvertOwner(roomAdvert) { + const { currentUser } = this.session; + return !isNone(currentUser) && roomAdvert.isOwner(currentUser); + } +} diff --git a/app/components/cards/article-card.hbs b/app/components/cards/article-card.hbs index a126dae8c..8558b4fd7 100644 --- a/app/components/cards/article-card.hbs +++ b/app/components/cards/article-card.hbs @@ -102,7 +102,7 @@ {{#if useMaxHeight}} {{/if}} diff --git a/app/components/cards/public-room-advert-card.hbs b/app/components/cards/public-room-advert-card.hbs new file mode 100644 index 000000000..664c90042 --- /dev/null +++ b/app/components/cards/public-room-advert-card.hbs @@ -0,0 +1,76 @@ +
+
+
+ {{#if (not @collapsed)}} + + {{/if}} +
+
+
+ {{#if @collapsed}} +
+

{{@roomAdvert.houseName}}

+
+
+ {{/if}} + + {{#if @roomAdvert.location}} + + + + + {{/if}} + {{#if @roomAdvert.availableFrom}} + + + + + {{/if}} + + + + +
{{t 'component.public.roomForum.location'}} + + {{@roomAdvert.location}} + +
{{t 'component.public.roomForum.availableFrom'}}{{moment-format @roomAdvert.availableFrom 'DD-M-YYYY'}}
{{t 'component.public.roomForum.contact'}} + {{#if (is-phone @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else if (is-email @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else if (is-url @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else}} + {{@roomAdvert.contact}} + {{/if}} +
+
+ {{#if (and @roomAdvert.coverPhotoUrl @collapsed)}} + + {{/if}} +
+

+ {{markdown-to-html + @roomAdvert.descriptionCamofied + extensions='youtubeEmbed bootstrapTable' + }} +

+

+ {{#if @collapsed}} + + {{/if}} +
+
+
+
\ No newline at end of file diff --git a/app/components/cards/public-room-advert-card.js b/app/components/cards/public-room-advert-card.js new file mode 100644 index 000000000..c75c19361 --- /dev/null +++ b/app/components/cards/public-room-advert-card.js @@ -0,0 +1,11 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; + +export default class PublicRoomAdvertCardComponent extends Component { + @action + open(advert) { + if (this.args.open) { + this.args.open(advert); + } + } +} diff --git a/app/components/cards/room-advert-card.hbs b/app/components/cards/room-advert-card.hbs new file mode 100644 index 000000000..bd6024dab --- /dev/null +++ b/app/components/cards/room-advert-card.hbs @@ -0,0 +1,72 @@ +
+
+ + +
+ +
+

+ {{@roomAdvert.houseName}} +

+

+ + + {{@roomAdvert.author.fullName}} + + +

+
+
+
+ +
+ {{#if @roomAdvert.location}} + + {{/if}} + + {{#if @roomAdvert.availableFrom}} +
+ Beschikbaar vanaf: + {{moment-format @roomAdvert.availableFrom 'DD-M-YYYY'}} +
+ {{/if}} +
+ +
+

+ {{markdown-to-html + @roomAdvert.descriptionCamofied + extensions='youtubeEmbed bootstrapTable' + }} +

+
+ + {{#if @roomAdvert.contact}} +
+
+ Contact: + {{#if (is-phone @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else if (is-email @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else if (is-url @roomAdvert.contact)}} + {{@roomAdvert.contact}} + {{else}} + {{@roomAdvert.contact}} + {{/if}} +
+
+ {{/if}} +
\ No newline at end of file diff --git a/app/components/forms/room-advert-form.hbs b/app/components/forms/room-advert-form.hbs new file mode 100644 index 000000000..7c9139f01 --- /dev/null +++ b/app/components/forms/room-advert-form.hbs @@ -0,0 +1,81 @@ +
+
+
{{if @model.isNew 'Kamer advertentie aanmaken' 'Kamer advertentie wijzigen'}}
+
+
+
+ + + + + + + + {{#if @model.publiclyVisible}} +
+
+ +
+
+ {{/if}} + + + + + + + +
+
\ No newline at end of file diff --git a/app/components/header-nav.hbs b/app/components/header-nav.hbs index cc2df8113..4740e450e 100644 --- a/app/components/header-nav.hbs +++ b/app/components/header-nav.hbs @@ -1,49 +1,51 @@ -