Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer 2 header migration #702

Merged
merged 42 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9e329b5
feat(polymer2-header-migration):
daniel-tabarcea Feb 14, 2018
b9d9c96
feat(polymer2-header-migration):
daniel-tabarcea Feb 14, 2018
c0be3d4
feat(polymer2-header-migration):
daniel-tabarcea Feb 15, 2018
a1c36b0
feat(polymer2-header-migration):
daniel-tabarcea Feb 15, 2018
8c86a52
pulled from base branch, fixed conflicts
daniel-tabarcea Feb 15, 2018
ece05d8
indentation fix
daniel-tabarcea Feb 15, 2018
dbfcc7e
pulled from base branch, fixed conflicts
daniel-tabarcea Feb 16, 2018
6274412
feat(polymer2-header-migration):
daniel-tabarcea Feb 16, 2018
9bd0714
feat(polymer2-header-migration):
daniel-tabarcea Feb 16, 2018
3a7ec34
feat(polymer2-header-migration):
daniel-tabarcea Feb 16, 2018
0af70af
updated dependencies versions
daniel-tabarcea Feb 20, 2018
4eac699
updated package version
daniel-tabarcea Feb 20, 2018
b32221c
Merge branch 'feat--polymer2-header-migration' of https://github.com/…
daniel-tabarcea Feb 20, 2018
00064f8
pulled from base branch, fixed conflicts
daniel-tabarcea Feb 20, 2018
41e0706
updated package versions
daniel-tabarcea Feb 20, 2018
a40c2b4
removed unsued package
daniel-tabarcea Feb 20, 2018
d4ea7f7
feat(polymer2-header-migration):
daniel-tabarcea Feb 21, 2018
a65a8e1
pulled from base branch, fixed conflicts
daniel-tabarcea Feb 21, 2018
b750043
fixed spacing
daniel-tabarcea Feb 21, 2018
7e71fd5
updated package version
daniel-tabarcea Feb 21, 2018
469d9da
feat(polymer2-header-migration):
daniel-tabarcea Feb 21, 2018
bc62d87
added missing anotation
daniel-tabarcea Feb 21, 2018
23e90d8
changed dependency oder
daniel-tabarcea Feb 21, 2018
78e2183
feat(polymer2-header-migration)
daniel-tabarcea Feb 21, 2018
d8957d4
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
9124241
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
36b000a
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
e525715
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
531f2e4
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
4f18b5b
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
a5dda14
feat(polymer2-header-migration):
daniel-tabarcea Feb 22, 2018
9b36aad
fix(event-handlers):
daniel-tabarcea Feb 22, 2018
51c8e4e
fix(event-handlers):
daniel-tabarcea Feb 22, 2018
5b19af9
fix(event-handlers):
daniel-tabarcea Feb 22, 2018
6dae1bb
relaced dexie import from etools-ajax with local one
daniel-tabarcea Feb 23, 2018
58d5c31
Update bower.json
daniel-tabarcea Feb 26, 2018
4a7c838
Merge branch 'feature--polymer2-migration' of https://github.com/unic…
daniel-tabarcea Feb 26, 2018
2f11faa
removed empty file
daniel-tabarcea Feb 26, 2018
28d53b7
Merge branch 'feat--polymer2-header-migration' into fix--event-handlers
acory Feb 26, 2018
ab8024a
code review fixes
daniel-tabarcea Feb 26, 2018
43769d1
Merge pull request #710 from unicef/fix--event-handlers
acory Feb 26, 2018
c3ee3d8
Sort bower.json
acory Feb 26, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bower_components/
build/
node_modules/
.idea/
.vscode/
package-lock.json
8 changes: 6 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@
"iron-pages": "PolymerElements/iron-pages#^2.0.0",
"iron-selector": "PolymerElements/iron-selector#^2.0.1",
"iron-icons": "PolymerElements/iron-icons#^2.0.1",
"iron-label": "^2.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#^2.0.0",
"paper-button": "PolymerElements/paper-button#^2.0.0",
"paper-tooltip": "PolymerElements/paper-tooltip#^2.0.1",
"paper-ripple": "PolymerElements/paper-ripple#^2.0.1",
"paper-styles": "PolymerElements/paper-styles#^2.0.0",
"paper-toast": "PolymerElements/paper-toast#^2.0.0",
"paper-dropdown-menu": "^2.0.2",
"paper-progress": "PolymerElements/paper-progress#^2.0.1",
"paper-input": "PolymerElements/paper-input#^2.1.1",
"paper-tabs": "PolymerElements/paper-tabs#^2.0.0",
"paper-listbox": "^2.0.0",
"paper-checkbox": "^2.0.2",
"paper-menu-button": "PolymerElements/paper-menu-button#^2.1.0",
"paper-listbox": "PolymerElements/paper-listbox#^2.0.0",
"paper-item": "PolymerElements/paper-item#^2.1.0",
"etools-behaviors": "5a1b488",
"etools-loading": "6bdf1e7",
"etools-ajax": "6e15107",
"etools-piwik-analytics": "ab010e4",
"etools-app-selector": "98b8807",
"etools-app-selector": "c1a82bd",
"etools-profile-dropdown": "d5e2396",
"etools-file": "f98a943",
"etools-content-panel": "918bd21",
"etools-datepicker": "49455be",
Expand Down
15 changes: 7 additions & 8 deletions pmp/app-shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<link rel="import" href="modules/layout/menu/styles/app-drawer-styles.html">
<link rel="import" href="modules/layout/menu/app-sidebar-menu.html">
<link rel="import" href="modules/layout/menu/mixins/app-menu-mixin.html">
<link rel="import" href="modules/layout/components/data-refresh-dialog.html">

<!--import header and footer elements-->
<link rel="import" href="modules/layout/page-header.html">
Expand All @@ -51,8 +52,8 @@
<link rel="import" href="modules/toast-notifications/toast-notifications-mixin.html">
<link rel="import" href="modules/toast-notifications/toast-notifications-style.html">

<!-- import user data element -->
<link rel="import" href="modules/user/user-data.html">
<!-- import user data mixin -->
<link rel="import" href="modules/user/user-data-mixin.html">

<!-- import environment flags -->
<link rel="import" href="modules/environment-flags/environment-flags-mixin.html">
Expand Down Expand Up @@ -138,8 +139,6 @@
<!--user="[[user]]"-->
<!--toast="[[currentToastMessage]]"></etools-piwik-analytics>-->

<user-data user="{{user}}" permissions="{{permissions}}"></user-data>

<app-location
route="{{route}}"
url-space-regex="^[[rootPath]]">
Expand Down Expand Up @@ -167,7 +166,7 @@
<app-header-layout id="appHeadLayout" fullbleed has-scrolling-region>

<app-header slot="header" condenses reveals effects="waterfall">
<page-header id="pageheader" title="eTools" user="[[user]]"></page-header>
<page-header id="pageheader" title="eTools"></page-header>
</app-header>

<div id="page-container" class$="[[_getPageContainerClass(amendmentModeActive)]]">
Expand Down Expand Up @@ -225,8 +224,7 @@
</app-header-layout>
</app-drawer-layout>

<!-- TODO: polymer2 - uncomment this after data refresh dialog is element is ready -->
<!--<data-refresh-dialog id="dataRefreshDialog" page="{{module}}"></data-refresh-dialog>-->
<data-refresh-dialog id="dataRefreshDialog" page="{{module}}"></data-refresh-dialog>

<!-- TODO: polymer2 - static data load here -->
<static-common-data></static-common-data>
Expand All @@ -249,11 +247,12 @@
* @appliesMixin EtoolsPmpApp.Mixins.EnvironmentFlags
* @appliesMixin EtoolsPmpApp.Mixins.ScrollControl
* @appliesMixin EtoolsPmpApp.Mixins.AmendmentMode
* @appliesMixin EtoolsPmpApp.Mixins.UserData
*/
const AppShellRequiredMixins = EtoolsMixinFactory.combineMixins(
[EtoolsPmpApp.Mixins.AppMenu, EtoolsPmpApp.Mixins.ToastNotifications, EtoolsMixins.LoadingMixin,
EtoolsPmpApp.Mixins.EnvironmentFlags, EtoolsPmpApp.Mixins.ScrollControl,
EtoolsPmpApp.Mixins.AmendmentMode], Polymer.Element);
EtoolsPmpApp.Mixins.AmendmentMode, EtoolsPmpApp.Mixins.UserData], Polymer.Element);

/**
* PMP main element used to configure and display all app modules
Expand Down
182 changes: 182 additions & 0 deletions pmp/modules/layout/components/countries-dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<link rel="import" href="../../../../bower_components/polymer/polymer.html">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong import, polymer-element.html is used in Polymer 2

<link rel="import" href="../../../../bower_components/etools-behaviors/etools-mixin-factory.html">
<link rel="import" href="../../../../bower_components/etools-behaviors/etools-page-refresh-mixin.html">
<link rel="import" href="../../../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../../../bower_components/etools-ajax/etools-ajax-request-mixin.html">
<link rel="import" href="../../endpoints/endpoints-mixin.html">
<dom-module id="countries-dropdown">
<template strip-whitespace>
<style>

:host {
display: block;
}

:host(:hover) {
cursor: pointer;
}

paper-dropdown-menu {
width: 160px;
--paper-input-container-color: var(--countries-dropdown-color);
--paper-input-container-focus-color: var(--countries-dropdown-color);
--paper-input-container-underline: {
display: none;
};
--paper-input-container-underline-focus: {
display: none;
};
--paper-input-container-underline-disabled: {
display: none;
};

--paper-dropdown-menu-icon: {
color: var(--countries-dropdown-color);
align-self: flex-end;
};

--paper-input-container-label: {
top: 4px;
};
--paper-input-container-input: {
color: var(--countries-dropdown-color);
cursor: pointer;
min-height: 24px;
text-align: right;
};
--paper-menu-button-dropdown: {
max-height: 380px;
}
}

paper-item {
font-size: 15px;
white-space: nowrap;
cursor: pointer;
}

iron-icon {
bottom: 2px;
min-width: 24px;
min-height: 20px;
margin-right: 8px;
}

paper-item iron-icon {
margin-right: 16px;
}
</style>

<template is="dom-if" if="[[countrySelectorVisible]]">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dom-if.html and dom-repeat.html import missing

<paper-dropdown-menu id="menu" label="Country" noink no-label-float>
<paper-listbox slot="dropdown-content"
id="countriesListbox"
attr-for-selected="countryId"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be country-id?

selected="[[currentCountry.id]]"
on-iron-select="_countrySelected">
<template id="repeat" is="dom-repeat" items="[[countries]]">
<paper-item country-id="[[item.id]]">
[[item.name]]
</paper-item>
</template>
</paper-listbox>

</paper-dropdown-menu>
</template>
</template>

<script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'use strict'; missing

/**
* @polymer
* @mixinFunction
* @appliedMixin EtoolsLogsMixin
* @appliedMixin EtoolsAjaxRequestMixin
* @appliedMixin EtoolsPageRefreshMixin
* @appliedMixin EtoolsPmpApp.Mixins.Endpoints
*/
const CountriesDropdownMixin = EtoolsMixinFactory.combineMixins(
[EtoolsLogsMixin, EtoolsAjaxRequestMixin, EtoolsPageRefreshMixin,
EtoolsPmpApp.Mixins.Endpoints], Polymer.Element);

/**
*
* @polymer
* @customElement
* @appliedMixin CountriesDropdownMixin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@appliesMixin... :)

*/
class CountriesDropdown extends CountriesDropdownMixin {

static get is() {
return 'countries-dropdown';
}

static get properties() {
return {
currentCountry: {
type: Object
},
countries: {
type: Array,
observer: '_countrySelectorUpdate'
},
countrySelectorVisible: Boolean
};
}

_countrySelected(e) {
if (e.detail.item.countryId !== this.currentCountry.id) {
//send post request to change_coutry endpoint
let selectedCountryId = e.detail.item.countryId;
this._triggerCountryChangeRequest(selectedCountryId);
}
}

_triggerCountryChangeRequest(countryId) {
this.dispatchEvent(new CustomEvent('global-loading', {
message: 'Please wait while country is changing...',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event bubbles and composed properties missing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the event should be defined like this:

this.dispatchEvent(new CustomEvent('global-loading',  {detail: {message: '...', active: true, loadingSource: '...'}, bubbles: true, composed: true});

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all PR events should be fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active: true,
loadingSource: 'country-change'
}));
let self = this;

this.sendRequest({
endpoint: this.getEndpoint('changeCountry'),
method: 'POST',
body: {country: countryId}
}).then(function(resp) {
self._handleResponse();
}).catch(function(error) {
self._handleError(error);
});
}

_handleResponse() {
this.dispatchEvent(new CustomEvent('update-main-path', {path: ''}));
// TODO: refresh method will be removed once etools-ajax v2 is used and the app uses only one dexie db
// TODO for TODO - refresh method is used elsewhere also and the code relies on the redirect trigerred
// by the refresh method
this.refresh();
}

_countrySelectorUpdate(countries) {
if (Array.isArray(countries) && (countries.length > 1)) {
this.countrySelectorVisible = true;
}
}

_handleError(error) {
this.logError('Country change failed!', 'countries-dropdown', error);
// TODO: this should be a larger alert.
this.$.countriesListbox.selected = this.currentCountry;
this.dispatchEvent(new CustomEvent('toast', {text: 'Something went wrong changing your workspace. Please try again'}));
this.dispatchEvent(new CustomEvent('global-loading', {active: false, loadingSource: 'country-change'}));
}

}

window.customElements.define(CountriesDropdown.is, CountriesDropdown);
</script>

</dom-module>
Loading