Skip to content

Commit

Permalink
feat(admin-ui): Extend custom field controls to support new options
Browse files Browse the repository at this point in the history
Relates to #85
  • Loading branch information
michaelbromley committed Jul 16, 2019
1 parent af13dc2 commit 019cd02
Show file tree
Hide file tree
Showing 15 changed files with 741 additions and 216 deletions.
241 changes: 182 additions & 59 deletions admin-ui/src/app/common/generated-types.ts

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions admin-ui/src/app/common/introspection-result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
export interface IntrospectionResultData {
__schema: {
types: Array<{
kind: string;
name: string;
possibleTypes: Array<{
name: string;
}>;
}>;
};
}

const result: IntrospectionResultData = {
__schema: {
types: [
{
kind: 'INTERFACE',
name: 'PaginatedList',
possibleTypes: [
{
name: 'AdministratorList',
},
{
name: 'AssetList',
},
{
name: 'CollectionList',
},
{
name: 'ProductVariantList',
},
{
name: 'OrderList',
},
{
name: 'HistoryEntryList',
},
{
name: 'CountryList',
},
{
name: 'CustomerList',
},
{
name: 'FacetList',
},
{
name: 'PaymentMethodList',
},
{
name: 'ProductList',
},
{
name: 'PromotionList',
},
{
name: 'RoleList',
},
{
name: 'ShippingMethodList',
},
{
name: 'TaxRateList',
},
],
},
{
kind: 'INTERFACE',
name: 'Node',
possibleTypes: [
{
name: 'Administrator',
},
{
name: 'User',
},
{
name: 'Role',
},
{
name: 'Channel',
},
{
name: 'Zone',
},
{
name: 'Country',
},
{
name: 'Asset',
},
{
name: 'Collection',
},
{
name: 'ProductVariant',
},
{
name: 'TaxRate',
},
{
name: 'TaxCategory',
},
{
name: 'CustomerGroup',
},
{
name: 'ProductOption',
},
{
name: 'FacetValue',
},
{
name: 'Facet',
},
{
name: 'StockAdjustment',
},
{
name: 'Sale',
},
{
name: 'OrderLine',
},
{
name: 'OrderItem',
},
{
name: 'Fulfillment',
},
{
name: 'Order',
},
{
name: 'Customer',
},
{
name: 'Address',
},
{
name: 'Payment',
},
{
name: 'Refund',
},
{
name: 'ShippingMethod',
},
{
name: 'HistoryEntry',
},
{
name: 'Cancellation',
},
{
name: 'Return',
},
{
name: 'PaymentMethod',
},
{
name: 'ProductOptionGroup',
},
{
name: 'Product',
},
{
name: 'Promotion',
},
],
},
{
kind: 'UNION',
name: 'StockMovementItem',
possibleTypes: [
{
name: 'StockAdjustment',
},
{
name: 'Sale',
},
{
name: 'Cancellation',
},
{
name: 'Return',
},
],
},
{
kind: 'INTERFACE',
name: 'StockMovement',
possibleTypes: [
{
name: 'StockAdjustment',
},
{
name: 'Sale',
},
{
name: 'Cancellation',
},
{
name: 'Return',
},
],
},
{
kind: 'UNION',
name: 'CustomFieldConfig',
possibleTypes: [
{
name: 'StringCustomFieldConfig',
},
{
name: 'LocaleStringCustomFieldConfig',
},
{
name: 'IntCustomFieldConfig',
},
{
name: 'FloatCustomFieldConfig',
},
{
name: 'BooleanCustomFieldConfig',
},
{
name: 'DateTimeCustomFieldConfig',
},
],
},
{
kind: 'INTERFACE',
name: 'CustomField',
possibleTypes: [
{
name: 'StringCustomFieldConfig',
},
{
name: 'LocaleStringCustomFieldConfig',
},
{
name: 'IntCustomFieldConfig',
},
{
name: 'FloatCustomFieldConfig',
},
{
name: 'BooleanCustomFieldConfig',
},
{
name: 'DateTimeCustomFieldConfig',
},
],
},
{
kind: 'UNION',
name: 'SearchResultPrice',
possibleTypes: [
{
name: 'PriceRange',
},
{
name: 'SinglePrice',
},
],
},
],
},
};

export default result;
9 changes: 7 additions & 2 deletions admin-ui/src/app/data/data.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
import { ApolloClientOptions } from 'apollo-client';
import { ApolloLink } from 'apollo-link';
import { setContext } from 'apollo-link-context';
import { createUploadLink } from 'apollo-upload-client';

import { environment } from '../../environments/environment';
import { getAppConfig } from '../app.config';
import introspectionResult from '../common/introspection-result';
import { LocalStorageService } from '../core/providers/local-storage/local-storage.service';

import { clientDefaults } from './client-state/client-defaults';
Expand All @@ -27,7 +28,11 @@ export function createApollo(
const { apiHost, apiPort, adminApiPath } = getAppConfig();
const host = apiHost === 'auto' ? `${location.protocol}//${location.hostname}` : apiHost;
const port = apiPort === 'auto' ? (location.port === '' ? '' : `:${location.port}`) : `:${apiPort}`;
const apolloCache = new InMemoryCache();
const apolloCache = new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData: introspectionResult,
}),
});
apolloCache.writeData({
data: clientDefaults,
});
Expand Down

0 comments on commit 019cd02

Please sign in to comment.