diff --git a/app/components/-forms/campaign/create.js b/app/components/-forms/campaign/create.js index 17963f75..7ea763c6 100644 --- a/app/components/-forms/campaign/create.js +++ b/app/components/-forms/campaign/create.js @@ -25,7 +25,7 @@ export default Component.extend(ActionMixin, ComponentQueryManager, { const key = `create${classify(type)}Campaign`; - const { advertiser, name, story } = this.get('model'); + const { advertiser, publisher, name, story } = this.get('model'); const input = { name }; if (['new-story', 'external-url'].includes(type)) { input.advertiserId = get(advertiser, 'id'); @@ -33,6 +33,9 @@ export default Component.extend(ActionMixin, ComponentQueryManager, { if (type === 'existing-story') { input.storyId = get(story, 'id'); } + if (type === 'new-story') { + input.publisherId = get(publisher, 'id'); + } const mutation = this.get(key); const variables = { input }; diff --git a/app/components/-forms/story/-fields/publisher.js b/app/components/-forms/story/-fields/publisher.js new file mode 100644 index 00000000..169edf4c --- /dev/null +++ b/app/components/-forms/story/-fields/publisher.js @@ -0,0 +1,20 @@ +import Component from '@ember/component'; +import { inject } from '@ember/service'; + +export default Component.extend({ + autocomplete: inject(), + + classNames: ['form-group'], + value: null, + + actions: { + /** + * Performs the advertiser autocomplete search. + * + * @param {*} phrase + */ + search(phrase) { + return this.get('autocomplete').query('publishers', phrase); + }, + }, +}); diff --git a/app/controllers/manage/advertiser/edit/index.js b/app/controllers/manage/advertiser/edit/index.js index e875131f..ffdd4481 100644 --- a/app/controllers/manage/advertiser/edit/index.js +++ b/app/controllers/manage/advertiser/edit/index.js @@ -42,7 +42,7 @@ export default Controller.extend(ActionMixin, { * * @param {object} fields */ - async update({ id, name, notify }) { + async update({ id, name, website, notify }) { this.startAction(); const promises = []; ['internal', 'external'].forEach((type) => { @@ -52,7 +52,7 @@ export default Controller.extend(ActionMixin, { const mutation = setContacts; promises.push(this.get('apollo').mutate({ mutation, variables }, 'setAdvertiserContacts')); }); - const payload = { name }; + const payload = { name, website }; const variables = { input: { id, payload } }; const mutation = updateAdvertiser; diff --git a/app/controllers/manage/publisher/create.js b/app/controllers/manage/publisher/create.js index 2abbb16e..56d71c4e 100644 --- a/app/controllers/manage/publisher/create.js +++ b/app/controllers/manage/publisher/create.js @@ -12,9 +12,9 @@ export default Controller.extend(ActionMixin, { * * @param {object} fields */ - async create({ name }) { + async create({ name, website }) { this.startAction(); - const payload = { name }; + const payload = { name, website }; const variables = { input: { payload } }; try { const response = await this.get('apollo').mutate({ mutation, variables }, 'createPublisher'); diff --git a/app/controllers/manage/publisher/edit/index.js b/app/controllers/manage/publisher/edit/index.js index da84130a..82738eab 100644 --- a/app/controllers/manage/publisher/edit/index.js +++ b/app/controllers/manage/publisher/edit/index.js @@ -59,9 +59,9 @@ export default Controller.extend(ActionMixin, { * * @param {object} fields */ - async update({ id, name }) { + async update({ id, name, website }) { this.startAction(); - const payload = { name }; + const payload = { name, website }; const variables = { input: { id, payload } }; try { await this.get('apollo').mutate({ mutation: updatePublisher, variables }, 'updatePublisher'); diff --git a/app/controllers/manage/story/create.js b/app/controllers/manage/story/create.js index 7d391c8b..66a8717b 100644 --- a/app/controllers/manage/story/create.js +++ b/app/controllers/manage/story/create.js @@ -13,12 +13,18 @@ export default Controller.extend(ActionMixin, { * * @param {object} fields */ - async create({ title, advertiser, publishedAt }) { + async create() { this.startAction(); + const { + title, + advertiser, + publisher, + } = this.get('model'); + const payload = { title, advertiserId: get(advertiser || {}, 'id'), - publishedAt: publishedAt ? publishedAt.valueOf() : null, + publisherId: get(publisher || {}, 'id'), }; const variables = { input: { payload } }; try { diff --git a/app/controllers/manage/story/edit/index.js b/app/controllers/manage/story/edit/index.js index 6bdd9a8f..784a49d8 100644 --- a/app/controllers/manage/story/edit/index.js +++ b/app/controllers/manage/story/edit/index.js @@ -15,13 +15,14 @@ export default Controller.extend(ActionMixin, { * * @param {object} fields */ - async update({ id, advertiser, title, teaser, body, publishedAt }) { + async update({ id, advertiser, publisher, title, teaser, body, publishedAt }) { this.startAction(); const payload = { title, teaser, body, advertiserId: get(advertiser || {}, 'id'), + publisherId: get(publisher || {}, 'id'), publishedAt: publishedAt ? publishedAt.valueOf() : null, }; const variables = { input: { id, payload } }; diff --git a/app/gql/fragments/advertiser/edit.graphql b/app/gql/fragments/advertiser/edit.graphql index dcdaa766..119aa080 100644 --- a/app/gql/fragments/advertiser/edit.graphql +++ b/app/gql/fragments/advertiser/edit.graphql @@ -4,6 +4,7 @@ fragment AdvertiserEditFragment on Advertiser { id name + website hash logo { ...ImageSrcFragment diff --git a/app/gql/fragments/publisher/edit.graphql b/app/gql/fragments/publisher/edit.graphql index 8a0b8b0f..e505a28d 100644 --- a/app/gql/fragments/publisher/edit.graphql +++ b/app/gql/fragments/publisher/edit.graphql @@ -3,6 +3,7 @@ fragment PublisherEditFragment on Publisher { id name + website createdAt updatedAt domainName diff --git a/app/gql/fragments/story/list.graphql b/app/gql/fragments/story/list.graphql index 994173fd..8cbd521d 100644 --- a/app/gql/fragments/story/list.graphql +++ b/app/gql/fragments/story/list.graphql @@ -9,6 +9,10 @@ fragment StoryListFragment on Story { id name } + publisher { + id + name + } status publishedAt primaryImage { diff --git a/app/gql/fragments/story/view.graphql b/app/gql/fragments/story/view.graphql index 0220f19a..3f4faa97 100644 --- a/app/gql/fragments/story/view.graphql +++ b/app/gql/fragments/story/view.graphql @@ -12,6 +12,10 @@ fragment StoryFragment on Story { id hash } + publisher { + id + name + } primaryImage { ...ImageViewFragment } diff --git a/app/templates/components/-forms/campaign/create.hbs b/app/templates/components/-forms/campaign/create.hbs index 5684ee3b..85e5efe7 100644 --- a/app/templates/components/-forms/campaign/create.hbs +++ b/app/templates/components/-forms/campaign/create.hbs @@ -11,6 +11,7 @@ type=(component "-forms/campaign/-fields/type" form=form value=campaignType on-change=(action "setCampaignType")) name=(component "-forms/campaign/-fields/name" form=form value=model.name on-change=(action "setFieldValue")) advertiser=(component "-forms/campaign/-fields/advertiser" form=form disabled=isActionRunning value=model.advertiser on-change=(action "setFieldValue")) + publisher=(component "-forms/story/-fields/publisher" form=form disabled=isActionRunning value=model.publisher on-change=(action "setFieldValue")) story=(component "-forms/campaign/-fields/story" form=form disabled=isActionRunning value=model.story on-change=(action "setFieldValue")) ) buttons=(hash diff --git a/app/templates/components/-forms/story/-fields/publisher.hbs b/app/templates/components/-forms/story/-fields/publisher.hbs new file mode 100644 index 00000000..35ff8862 --- /dev/null +++ b/app/templates/components/-forms/story/-fields/publisher.hbs @@ -0,0 +1,22 @@ + +{{#form.elements.typeahead + id="story-publisher" + placeholder="Begin typing to search..." + autocomplete="off" + class="form-control" + name="publisher" + label="Primary Publisher" + value=model.publisher + disabled=disabled + required=true + aria-labeledby="story-publisher-help" + allowClear=false + on-search=(action "search") + on-change=on-change as |typeahead| +}} + {{#typeahead.element as |publisher|}} + {{publisher.name}} + {{/typeahead.element}} + {{typeahead.elements.invalid-feedback}} +{{/form.elements.typeahead}} +The primary publisher running the story. diff --git a/app/templates/components/story-published-at.hbs b/app/templates/components/story-published-at.hbs index da36b0cb..4f6c5764 100644 --- a/app/templates/components/story-published-at.hbs +++ b/app/templates/components/story-published-at.hbs @@ -5,8 +5,9 @@ {{#if publishedAt}} {{moment-format publishedAt displayFormat}} {{else}} - Not Published (Draft) + Not Published {{/if}} + ({{story-status status=status}})
+
+
+
+ + {{input + type="url" + value=form.model.website + class="form-control" + id="website" + focusOut=(action form.actions.autosave) + keyUp=(action form.actions.autosave 750) + }} +
+ Please provide a valid website. +
+
+
+
+
diff --git a/app/templates/manage/campaign/create.hbs b/app/templates/manage/campaign/create.hbs index 0d65bc52..75db8148 100644 --- a/app/templates/manage/campaign/create.hbs +++ b/app/templates/manage/campaign/create.hbs @@ -32,6 +32,14 @@
+ {{#if (eq form.campaignType 'new-story')}} +
+
+ {{form.fields.publisher class="mb-0 mt-3"}} +
+
+ {{/if}} +
+
+
+
+ + {{input + type="url" + required=true + value=form.model.website + class="form-control" + id="publisher-website" + placeholder="https://www.publisher-website.com" + focusOut=(action form.actions.autosave) + keyUp=(action form.actions.autosave 750) + }} +
+ Please provide a publisher website. +
+
+
+
+ {{#if model.id}}
-
+
{{input type="text" diff --git a/app/templates/manage/story/fields/publisher.hbs b/app/templates/manage/story/fields/publisher.hbs new file mode 100644 index 00000000..9811aef3 --- /dev/null +++ b/app/templates/manage/story/fields/publisher.hbs @@ -0,0 +1,17 @@ +
+ + {{#type-ahead + required=true + wasFormValidated=form.wasValidated + invalidFeedback="Please select a publisher." + triggerClass="form-control" + placeholder="Begin typing to search..." + type="publisher" + closeOnSelect=true + allowClear=false + onChange=(action form.actions.autosave) + selected=form.model.publisher as |item| + }} + {{item.name}} + {{/type-ahead}} +
diff --git a/app/templates/manage/story/forms/create.hbs b/app/templates/manage/story/forms/create.hbs index d12c524f..d37832bf 100644 --- a/app/templates/manage/story/forms/create.hbs +++ b/app/templates/manage/story/forms/create.hbs @@ -9,12 +9,6 @@ {{partial "manage/story/fields/advertiser"}}
-
- - {{story-published-at - publishedAt=form.model.publishedAt - onSelect=(action form.actions.setAndAutosave "publishedAt") - }} -
+ {{partial "manage/story/fields/publisher"}}
diff --git a/app/templates/manage/story/forms/edit.hbs b/app/templates/manage/story/forms/edit.hbs index f11fa2c9..8dde8176 100644 --- a/app/templates/manage/story/forms/edit.hbs +++ b/app/templates/manage/story/forms/edit.hbs @@ -12,13 +12,7 @@ {{partial "manage/story/fields/advertiser"}}
-
- - {{story-published-at - publishedAt=form.model.publishedAt - onSelect=(action form.actions.setAndAutosave "publishedAt") - }} -
+ {{partial "manage/story/fields/publisher"}}
@@ -62,17 +56,17 @@ {{/link-to}} {{/if}} -
-
- {{entypo-icon "calendar"}} Published {{if model.publishedAt (moment-format model.publishedAt "MMM Do, YYYY @ h:mma") "N/A"}} -
-
-
-
- {{entypo-icon "flag"}} Status {{story-status status=model.status}} + +
+
+ {{story-published-at + publishedAt=form.model.publishedAt + status=form.model.status + onSelect=(action form.actions.setAndAutosave "publishedAt") + }}
-
+
Links
diff --git a/app/templates/manage/story/list-item.hbs b/app/templates/manage/story/list-item.hbs index 55b9b974..d24d5076 100644 --- a/app/templates/manage/story/list-item.hbs +++ b/app/templates/manage/story/list-item.hbs @@ -24,7 +24,7 @@

{{item.title}}

{{story-status status=item.status}}

-

Advertiser: {{item.advertiser.name}}

+

{{item.advertiser.name}} (via {{item.publisher.name}})

Campaigns: {{if item.campaigns.totalCount item.campaigns.totalCount 0}}

ID: {{item.id}}