Skip to content

Commit b61810a

Browse files
committed
Add mirage endpoints to create bulletin
1 parent 7447c4e commit b61810a

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

app/templates/bulletin/edit.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
clearbanner=(action "clearBanner")
77
diduploadaudio=(action "didUploadAudio")
88
diduploadbanner=(action "didUploadBanner")
9-
includesermon=true
109
onsave=(action "saveBulletin")
1110
removeannouncement=(action "removeAnnouncement")
1211
reorderannouncements=(action "reorderAnnouncements")}}

app/templates/components/bulletin-editor.hbs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,18 @@
4444
rows="10"}}
4545
</div>
4646
</div>
47-
{{#if this.attrs.includesermon}}
48-
<div class="panel panel-default">
49-
<fieldset>
50-
<div class="panel-heading">
51-
<h3 class="panel-title">Sermon</h3>
52-
</div>
53-
<div class="panel-body">
54-
{{sermon-editor sermon=bulletin.sermon
55-
diduploadaudio=(action this.attrs.diduploadaudio)
56-
clearaudio=(action this.attrs.clearaudio)}}
57-
</div>
58-
</fieldset>
59-
</div>
60-
{{/if}}
47+
<div class="panel panel-default">
48+
<fieldset>
49+
<div class="panel-heading">
50+
<h3 class="panel-title">Sermon</h3>
51+
</div>
52+
<div class="panel-body">
53+
{{sermon-editor sermon=bulletin.sermon
54+
diduploadaudio=(action this.attrs.diduploadaudio)
55+
clearaudio=(action this.attrs.clearaudio)}}
56+
</div>
57+
</fieldset>
58+
</div>
6159
</section>
6260
{{#if this.attrs.appendannouncement}}
6361
<section class="announcements col-md-6">

mirage/config.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import Mirage from "ember-cli-mirage";
2+
13
export default function() {
4+
this.post("/api/auth/sign_in", function(schema, request) {
5+
const user = schema.users.find(1);
6+
return new Mirage.Response(
7+
200,
8+
{ "access-token": "adssafsdafsdsfd", "client": "asdfasdfasafs", "uid": "[email protected]" },
9+
{"data":{"id":`${user.id}`,"type":"users","links":{"self":`/api/v1/users/${user.id}`},"attributes":{"name":user.name,"email":user.email}}}
10+
);
11+
});
12+
213
this.namespace = "/api/v1";
314

415
this.delete("/announcements/:id");
5-
this.get("/announcements");
616
this.get("/announcements/:id");
717
this.patch("/announcements/:id");
818
this.post("/announcements");
919

10-
this.get("/bulletins");
1120
this.get("/bulletins/:id");
1221
this.get("/bulletins/:id/sermon");
1322
this.patch("/bulletins/:id");
@@ -23,6 +32,24 @@ export default function() {
2332
this.patch("/sermons/:id");
2433
this.post("/sermons");
2534

35+
this.get("/bulletins", function(schema, request) {
36+
if (schema.bulletins.all().models.length > 0 &&
37+
request.queryParams["filter[latest_for_group]"]) {
38+
return schema.bulletins.find([1]);
39+
}
40+
41+
return schema.bulletins.all();
42+
});
43+
44+
this.get("/announcements", function(schema, request) {
45+
if (schema.announcements.all().models.length > 0 &&
46+
request.queryParams["filter[latest_for_group]"]) {
47+
return schema.announcements.find([1, 2, 3]);
48+
}
49+
50+
return schema.announcements.all();
51+
});
52+
2653
this.get("/posts", function(schema, request) {
2754
const groupId = request.queryParams["filter[group]"];
2855

mirage/scenarios/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ export default function(server) {
2222
}
2323

2424
server.createList("post", 10, { group: englishService });
25+
26+
server.create("user", { email: "[email protected]", name: "Test User" });
2527
}

0 commit comments

Comments
 (0)