Skip to content

Commit

Permalink
Merge pull request #4 from solocommand/pmmi-fields
Browse files Browse the repository at this point in the history
Pmmi fields
  • Loading branch information
solocommand authored Nov 8, 2019
2 parents b648b24 + 6adaa86 commit 616dfc7
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 87 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
1 change: 1 addition & 0 deletions app/app/gql/queries/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ query Config {
domain
logo
ids
isPmmi
}
}
14 changes: 12 additions & 2 deletions app/app/routes/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ export default Route.extend(RouteQueryManager, {
model() {
return this.get('apollo').watchQuery({ query, fetchPolicy: 'cache-and-network' }, 'config');
},
afterModel({ domain, logo, ids }) {
this.config.load({ domain, logo, ids });
afterModel({
domain,
logo,
ids,
isPmmi,
}) {
this.config.load({
domain,
logo,
ids,
isPmmi,
});
},
});
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}}
30 changes: 29 additions & 1 deletion app/app/templates/display/company/review/fields.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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=body options=options }}
{{ 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" }}">
Expand All @@ -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}}
12 changes: 12 additions & 0 deletions graph/src/definitions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = gql`
domain: String!
logo: String!
ids: [Int!]!
isPmmi: Boolean!
}
type CompanyUpdateSubmission {
Expand Down Expand Up @@ -84,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
1 change: 1 addition & 0 deletions graph/src/resolvers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const config = {
domain: PLATFORM_URI,
logo: PLATFORM_LOGO,
ids: PLATFORM_SECTIONS,
isPmmi: /^pmmi_/.test(B4GRAPH_TENANT_KEY),
};

module.exports = {
Expand Down

0 comments on commit 616dfc7

Please sign in to comment.