Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
50f656e
Revert "Fix for the theme test (#67)"
Novkirishki Nov 30, 2018
777efeb
Revert "Ability to customize new UI color schema (#62)"
Novkirishki Nov 30, 2018
105bbe5
Reverted changes to css locators. (#70)
dechoD Dec 3, 2018
68b4dee
Item onLoad hook (#63)
Novkirishki Dec 3, 2018
98b2a5f
Updated the progress-sitefinity-adminapp-sdk to 1.0.1 (#73)
dechoD Dec 7, 2018
f4a378b
Refactoring extensions E2E tests (#74)
dechoD Dec 11, 2018
6117eda
Pinned the chromedriver version (#81)
dechoD Dec 17, 2018
fe98e0e
Fix e2e tests (#83)
dechoD Dec 21, 2018
71ac109
Merge master to patches
Novkirishki Jan 18, 2019
80b9182
wip
Novkirishki Jan 18, 2019
9dfdee2
wip
Novkirishki Jan 18, 2019
f70424b
wip
Novkirishki Jan 18, 2019
fc2c87a
Make calls to API to get suggestions
Novkirishki Jan 18, 2019
3076e9a
Add tree to show suggestions
Novkirishki Jan 18, 2019
b9e6190
Merge branch 'master' into niki/addr-field
Novkirishki May 13, 2019
3fa6251
wip
Novkirishki May 13, 2019
85d91bb
persistance
Novkirishki May 13, 2019
d602ab6
fix
Novkirishki May 13, 2019
595e8e6
write value fix
Novkirishki May 13, 2019
f42bc90
Added address field for widget
ElenaGaneva May 13, 2019
6596a72
Make map interactive, add balloon to map
Novkirishki May 13, 2019
eaff780
Merge branch 'niki/addr-field' of https://github.com/Sitefinity/sitef…
Novkirishki May 13, 2019
a76e89e
Added other fields
Novkirishki May 14, 2019
24ac8e4
fix
Novkirishki May 14, 2019
c934202
Add keyboard controls
Novkirishki May 14, 2019
ad4028d
Fix initial location on map
Novkirishki May 14, 2019
187d620
fix lint
Novkirishki May 14, 2019
9bbd0ca
Fix double markers bug
Novkirishki May 14, 2019
5aa6948
Added reverse geocoding
Novkirishki May 14, 2019
0245087
Changed field name
ElenaGaneva May 14, 2019
8ce81d4
Merge branch 'niki/addr-field' of https://github.com/Sitefinity/sitef…
ElenaGaneva May 14, 2019
1e0c59c
Remove first field title
Novkirishki May 14, 2019
dab61d2
Config service
Novkirishki May 14, 2019
e350205
Fix clearing suggestions
Novkirishki May 14, 2019
bbc86c2
Fix lint
Novkirishki May 14, 2019
038ee91
Fix
Novkirishki May 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions custom-fields/address-custom-field/address-custom-field-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Injectable, ClassProvider } from "@angular/core";

import { FIELDS_PROVIDER_TOKEN, FieldData, FieldsProvider, SettingsBase } from "progress-sitefinity-adminapp-sdk/app/api/v1";
import { FieldRegistration } from "progress-sitefinity-adminapp-sdk/app/api/v1";
import { RegistrationPair } from "./../registration-pair";
import { AddressCustomFieldComponent } from "./address-custom-field.component";

/**
* The fields provider provides the overridden fields back to the AdminApp.
*/
@Injectable()
export class AddressCustomFieldProvider implements FieldsProvider {
private customFieldsMappings: RegistrationPair[];

constructor() {
this.customFieldsMappings = [];

this.registerCustomComponents();
this.registerCustomWidgetComponents();
}

/**
* This method gets called before each field is instantiated, allowing custom fields to be plugged in for any type.
* @param fieldRegistryKey The metadata needed to determine which field to display.
*/
overrideField(fieldRegistryKey: FieldData): FieldRegistration {
const registration: FieldRegistration = this.findRegistration(fieldRegistryKey);
return registration;
}

/**
* This method finds an implementation of the field to be overridden.
* @param fieldRegistryKey The metadata needed to determine which field to display.
*/
private findRegistration(fieldRegistryKey: FieldData): FieldRegistration {
for (const pair of this.customFieldsMappings) {
if (fieldRegistryKey.fieldName === pair.key.fieldName &&
fieldRegistryKey.fieldType === pair.key.fieldType) {
return pair.registration;
}
}

return null;
}

/**
* Initializes the custom field(component) registrations.
*/
private registerCustomComponents(): void {

// The field name is the name which identifies the field uniquely.
// The typename is the OData entity set name. It matches the url segment when navigating
// to the list view of the specific type.
const customInputKey: FieldData = {
fieldName: "HereAddress",
fieldType: "sf-text-area",
typeName: undefined
};

// The result field registration that will be returned to the AdminApp.
const customInputRegistration: FieldRegistration = {
writeComponent: AddressCustomFieldComponent,
readComponent: AddressCustomFieldComponent,
settingsType: SettingsBase
};

const customFieldRegistrationPair: RegistrationPair = {
key: customInputKey,
registration: customInputRegistration
};

this.customFieldsMappings.push(customFieldRegistrationPair);
}

private registerCustomWidgetComponents(): void {

// The field name is the name which identifies the field uniquely.
// The typename is the OData entity set name. It matches the url segment when navigating
// to the list view of the specific type.
const customInputKey: FieldData = {
fieldName: "Address",
fieldType: "sf-short-text",
typeName: "widget-HereAddress"
};

// The result field registration that will be returned to the AdminApp.
const customInputRegistration: FieldRegistration = {
writeComponent: AddressCustomFieldComponent,
readComponent: AddressCustomFieldComponent,
settingsType: SettingsBase
};

const customFieldRegistrationPair: RegistrationPair = {
key: customInputKey,
registration: customInputRegistration
};

this.customFieldsMappings.push(customFieldRegistrationPair);
}
}

/**
* Export a 'multi' class provider so that multiple instances of the same provider can coexist.
* This allows for more than one provider to be registered within one or more bundles.
*/
export const ADDRESS_CUSTOM_FIELDS_PROVIDER: ClassProvider = {
provide: FIELDS_PROVIDER_TOKEN,
useClass: AddressCustomFieldProvider,
multi: true
};
102 changes: 102 additions & 0 deletions custom-fields/address-custom-field/address-custom-field.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<div class="sf-field" >
<span sfTrackFocus
(contentFocusOut)="onFocusOut()">
<span class="sf-input sf-popup">
<input type="text"
#streetAddress
class="sf-input__field"
autocomplete="off"
(keydown.enter)="onEnterKey($event)"
(keydown.escape)="onEscapeKey()"
(keydown.arrowUp)="onFocusPreviousNode()"
(keydown.arrowDown)="onFocusNextNode()"
(input)="onNewInputValue({ label: $event.srcElement.value })"
[(ngModel)]="searchTerm">
<sf-popup [isOpen]="isPopupVisible">
<div class="sf-popup__content sf-dropdown -condensed">
<div *ngIf="searchTerm && !(hasSuggestions | async)" class="sf-dropdown__no-items">
No results found
</div>
<sf-tree
data-sftest="related-data_popup-tree"
#popupTree
focusFirstNode="true"
displayField="label"
[nodes]="suggestions$ | async"
look="flat condensed"
[config]="popupTreeConfig"
[textToMatch]="searchTerm"
(treeNodeClicked)="onNewItemSelected($event)">
</sf-tree>
</div>
</sf-popup>
</span>
</span>
</div>
<div class="sf-field" >
<fieldset>
<legend class="sf-field__label -legend">
Address line 2
</legend>
<span class="sf-input sf-popup">
<input type="text"
#streetAddress2
(input)="onNewInputValue({ label2: $event.srcElement.value })"
class="sf-input__field">
</span>
</fieldset>
</div>
<div class="sf-field" >
<fieldset>
<legend class="sf-field__label -legend">
Country
</legend>
<span class="sf-input sf-popup">
<input type="text"
#country
(input)="onNewInputValue({ address: { country: $event.srcElement.value }})"
class="sf-input__field">
</span>
</fieldset>
</div>
<div class="sf-field" >
<fieldset>
<legend class="sf-field__label -legend">
County/State/Province
</legend>
<span class="sf-input sf-popup">
<input type="text"
#county
(input)="onNewInputValue({ address: { county: $event.srcElement.value }})"
class="sf-input__field">
</span>
</fieldset>
</div>
<div class="sf-field" >
<fieldset>
<legend class="sf-field__label -legend">
Town/City
</legend>
<span class="sf-input sf-popup">
<input type="text"
#city
(input)="onNewInputValue({ address: { city: $event.srcElement.value }})"
class="sf-input__field">
</span>
</fieldset>
</div>
<div class="sf-field" >
<fieldset>
<legend class="sf-field__label -legend">
Postcode/Zip
</legend>
<span class="sf-input sf-popup">
<input type="text"
#postcode
(input)="onNewInputValue({ address: { postalCode: $event.srcElement.value }})"
class="sf-input__field">
</span>
</fieldset>
</div>

<div style="width: 640px; height: 480px" #mapContainer></div>
Loading