Skip to content

Commit

Permalink
Support additional PMMI fields
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Nov 8, 2019
1 parent d72b014 commit 6adaa86
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 84 deletions.
10 changes: 10 additions & 0 deletions app/app/components/submit-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import mutation from 'cuf/gql/mutations/company';
const fields = [
'address1',
'address2',
'teaser',
'body',
'city',
'country',
Expand All @@ -21,6 +22,15 @@ const fields = [
'zip',
'sectionIds',
'logo',
'numberOfEmployees',
'trainingInformation',
'yearsInOperation',
'salesRegion',
'servicesProvided',
'salesChannels',
'productSummary',
'serviceInformation',
'warrantyInformation',
];

const filterModel = (model = {}) => {
Expand Down
144 changes: 65 additions & 79 deletions app/app/controllers/display/company.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';

const fields = [
[
{ label: 'Name', key: 'name' }
],
[
{ label: 'Address 1', key: 'address1', class: 'col-md-4' },
{ label: 'Address 2', key: 'address2', class: 'col-md-4' },
{ label: 'City', key: 'city', class: 'col-md-4' },
],
[
{ label: 'State', key: 'state', class: 'col-md-4' },
{ label: 'Zip/Postal Code', key: 'zip', class: 'col-md-4' },
{ label: 'Country', key: 'country', class: 'col-md-4' },
],
[
{ label: 'Phone Number', key: 'phone', class: 'col-md-4' },
{ label: 'Phone (Toll-free)', key: 'tollfree', class: 'col-md-4' },
{ label: 'Fax Number', key: 'fax', class: 'col-md-4' },
],
[
{ label: 'Website', key: 'website', class: 'col-md-6' },
{ label: 'Email Address', key: 'email', class: 'col-md-6' },
],
[
{ label: 'Teaser', key: 'teaser', type: 'long' },
],
[
{ label: 'Description', key: 'body', type: 'long' },
],
];

const extra = [
[
{ label: 'Number of employees', key: 'numberOfEmployees', class: 'col-md-6' },
{ label: 'Years in operation', key: 'yearsInOperation', class: 'col-md-6' },
],
[
{ label: 'Sales regions', key: 'salesRegion', class: 'col-md-6' },
{ label: 'Sales channels', key: 'salesChannels', class: 'col-md-6' },
],
[
{ label: 'Product summary', key: 'productSummary', type: 'long' },
],
[
{ label: 'Training information', key: 'trainingInformation', type: 'long' },
],
[
{ label: 'Services provided', key: 'servicesProvided', type: 'long' },
],
[
{ label: 'Warranty information', key: 'warrantyInformation', type: 'long' },
],
[
{ label: 'Service information', key: 'serviceInformation', type: 'long' },
],
];

export default Controller.extend({
// Merges contacts into a single array
contacts: computed('model.{salesContacts,listingContacts,publicContacts}.[]', function() {
Expand All @@ -15,83 +72,12 @@ export default Controller.extend({
}),

// Determines display order, labels, and visibility/type of updateable fields
fields: [ // eslint-disable-line ember/avoid-leaking-state-in-ember-objects
[
{
label: 'Name',
key: 'name',
}
],
[
{
label: 'Address 1',
key: 'address1',
class: 'col-md-4',
},
{
label: 'Address 2',
key: 'address2',
class: 'col-md-4',
},
{
label: 'City',
key: 'city',
class: 'col-md-4',
},
],
[
{
label: 'State',
key: 'state',
class: 'col-md-4',
},
{
label: 'Zip/Postal Code',
key: 'zip',
class: 'col-md-4',
},
{
label: 'Country',
key: 'country',
class: 'col-md-4',
},
],
[
{
label: 'Phone Number',
key: 'phone',
class: 'col-md-4',
},
{
label: 'Phone (Toll-free)',
key: 'tollfree',
class: 'col-md-4',
},
{
label: 'Fax Number',
key: 'fax',
class: 'col-md-4',
},
],
[
{
label: 'Website',
key: 'website',
class: 'col-md-6',
},
{
label: 'Email Address',
key: 'email',
class: 'col-md-6',
},
],
[
{
label: 'Description',
key: 'body',
type: 'long',
},
],
],
});
fields: null,
extra: null,

init() {
this._super();
this.set('fields', fields);
this.set('extra', extra);
},
});
12 changes: 12 additions & 0 deletions app/app/gql/queries/company.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
query PlatformContentHash($input: Base4PlatformContentQueryHash!) {
base4PlatformContentHash(input: $input) {
name
teaser
hash
type
body
Expand All @@ -27,6 +28,17 @@ query PlatformContentHash($input: Base4PlatformContentQueryHash!) {
fax
website
email

numberOfEmployees
trainingInformation
yearsInOperation
salesRegion
servicesProvided
salesChannels
productSummary
serviceInformation
warrantyInformation

# sections {
# name
# children {
Expand Down
4 changes: 4 additions & 0 deletions app/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ body.transitioning {
border: 1px solid rgb(24, 188, 156);
border-right: none;
}

.froala-editor-container {
min-width: 100%;
}
19 changes: 14 additions & 5 deletions app/app/templates/display/company/edit/fields.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{{#each fields as |row|}}
<div class="row">
{{#each row as |field|}}
{{ edit-field field=field value=(get model field.key)}}
{{/each}}
</div>
<div class="row">
{{#each row as |field|}}
{{ edit-field field=field value=(get model field.key)}}
{{/each}}
</div>
{{/each}}
{{#if config.isPmmi}}
{{#each extra as |row|}}
<div class="row">
{{#each row as |field|}}
{{ edit-field field=field value=(get model field.key)}}
{{/each}}
</div>
{{/each}}
{{/if}}
28 changes: 28 additions & 0 deletions app/app/templates/display/company/review/fields.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,31 @@
{{/each}}
</div>
{{/each}}
{{#if config.isPmmi}}
{{#each extra as |row|}}
<div class="row">
{{#each row as |field|}}
<div class="col {{ field.class }}">
<div class="form-group">
<label for="{{ field.key }}-input">{{ field.label }}</label>
<div class="input-group">
{{#if (eq field.type "long")}}
<div class="form-control {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "field-modified" }}" style="height: inherit;">
{{ froala-editor content=(get model.submission.payload field.key) options=options }}
</div>
{{else}}
<div readonly class="form-control form-control-plaintext {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "field-modified" }}">
{{ get model.submission.payload field.key }}
</div>
{{/if}}
{{#unless (eq (get model.company field.key) (get model.submission.payload field.key))}}
{{ copyable-text value=(get model.submission.payload field.key)}}
{{/unless}}
</div>
<small id="{{ field.key }}-help" class="form-text text-muted">{{ field.helpText }}</small>
</div>
</div>
{{/each}}
</div>
{{/each}}
{{/if}}
11 changes: 11 additions & 0 deletions graph/src/definitions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ module.exports = gql`
email: String
body: String
teaser: String
numberOfEmployees: String
trainingInformation: String
yearsInOperation: String
salesRegion: String
servicesProvided: String
salesChannels: String
productSummary: String
serviceInformation: String
warrantyInformation: String
# contacts: [ContactPayloadInput]
sectionIds: [Int!]
# images: [ImagePayloadInput]
Expand Down

0 comments on commit 6adaa86

Please sign in to comment.