Skip to content

Commit 813ed0a

Browse files
committed
feat(behavior): expose inProgress property
Before this commit there was no way to know if the elements were entered or not into a signing-in/up process. Now, the elements expose a property "in-progress" that is turned to True when the api is waiting for Firebase reponse. closes #163
1 parent c66132e commit 813ed0a

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

login-fire-button.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@
138138
}
139139
</style>
140140

141-
<paper-button class$="btn btn--[[provider]] [[_miniClass]] [[_signOutClass]]" raised$="[[!flat]]" disabled$="[[_inProgress]]">
141+
<paper-button class$="btn btn--[[provider]] [[_miniClass]] [[_signOutClass]]" raised$="[[!flat]]" disabled$="[[inProgress]]">
142142
<iron-icon class="btn__icon" icon="login-fire-icons:[[provider]]" hidden$="[[_hideIcon]]"></iron-icon>
143143
<iron-icon class="btn__icon" icon="login-fire-icons:logout" hidden$="[[!_hideIcon]]"></iron-icon>
144144
<span class="btn__text">[[_text]]</span>
145-
<paper-progress class="btn-progress" hidden$="[[!_inProgress]]" disabled$="[[!_inProgress]]" indeterminate></paper-progress>
145+
<paper-progress class="btn-progress" hidden$="[[!inProgress]]" disabled$="[[!inProgress]]" indeterminate></paper-progress>
146146
</paper-button>
147147

148148
<firebase-auth id="auth"

login-fire-common-behavior.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,11 @@
299299
* @type {Boolean}
300300
* @default false
301301
*/
302-
_inProgress: {
302+
inProgress: {
303303
type: Boolean,
304-
value: false
304+
value: false,
305+
readOnly: true,
306+
notify: true
305307
}
306308
},
307309

@@ -327,7 +329,7 @@
327329
*/
328330
signOut: function() {
329331
// Skip processing of this method when we already have started a sign or signout process
330-
if (this._inProgress) {
332+
if (this.inProgress) {
331333
if (this.debug) {
332334
console.debug('Ignored signOut when already in progress');
333335
}
@@ -339,8 +341,8 @@
339341
}
340342

341343
if (!this.noSignOut && this.signedIn) {
342-
// Set _inProgress flag to true when a signout is started
343-
this._inProgress = true;
344+
// Set inProgress flag to true when a signout is started
345+
this._setInProgress(true);
344346
this.$.auth.signOut().then(this._fireEvent.bind(this));
345347
}
346348
},
@@ -381,8 +383,8 @@
381383
console.debug(error);
382384
}
383385
this.fire('error', error);
384-
// When an error event was fired, we have to set the _inProgress flag back to false
385-
this._inProgress = false;
386+
// When an error event was fired, we have to set the inProgress flag back to false
387+
this._setInProgress(false);
386388
},
387389

388390
/**
@@ -414,8 +416,8 @@
414416
console.debug('User signed out from', this.config.provider.name);
415417
}
416418
}
417-
// When signin or signout event was fired, we have to set the _inProgress flag back to false
418-
this._inProgress = false;
419+
// When signin or signout event was fired, we have to set the inProgress flag back to false
420+
this._setInProgress(false);
419421
},
420422

421423
/**

login-fire-form-behavior.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* @param {String} password
6565
*/
6666
signIn: function(email, password) {
67-
this._inProgress = true;
67+
this._setInProgress(true);
6868
this.$.auth
6969
.signInWithEmailAndPassword(email, password)
7070
.then(this._fireEvent.bind(this))
@@ -97,7 +97,7 @@
9797
*/
9898
signUp: function(email, password) {
9999
if (this.provider === 'email' && !this.noSignUp) {
100-
this._inProgress = true;
100+
this._setInProgress(true);
101101
this.$.auth
102102
.createUserWithEmailAndPassword(email, password)
103103
.then(this._fireEvent.bind(this))

login-fire-form.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@
200200
hidden$="[[!reenterPassword]]"
201201
required>
202202
</paper-input>
203-
<paper-button raised$="[[!flat]]" type="submit" on-click="_signUp" class="btn--signup" disabled$="[[_inProgress]]">
203+
<paper-button raised$="[[!flat]]" type="submit" on-click="_signUp" class="btn--signup" disabled$="[[inProgress]]">
204204
<span>[[localize('lf-signup-button')]]</span>
205-
<paper-progress class="btn-progress" hidden$="[[!_inProgress]]" disabled$="[[!_inProgress]]" indeterminate></paper-progress>
205+
<paper-progress class="btn-progress" hidden$="[[!inProgress]]" disabled$="[[!inProgress]]" indeterminate></paper-progress>
206206
</paper-button>
207207
<p class="signup-toggle">
208208
<span>[[localize('lf-already-have-account')]]</span>
@@ -218,9 +218,9 @@
218218
on-click="toggleShowResetPW" tabindex="0" noink>
219219
[[localize('lf-resetpw-link')]]</paper-button>
220220
</p>
221-
<paper-button raised$="[[!flat]]" type="submit" on-click="_signIn" class="btn--signin" disabled$="[[_inProgress]]">
221+
<paper-button raised$="[[!flat]]" type="submit" on-click="_signIn" class="btn--signin" disabled$="[[inProgress]]">
222222
<span>[[localize('lf-signin-button')]]</span>
223-
<paper-progress class="btn-progress" hidden$="[[!_inProgress]]" disabled$="[[!_inProgress]]" indeterminate></paper-progress>
223+
<paper-progress class="btn-progress" hidden$="[[!inProgress]]" disabled$="[[!inProgress]]" indeterminate></paper-progress>
224224
</paper-button>
225225
<template is="dom-if" if="[[!noSignUp]]">
226226
<p class="signup-toggle">
@@ -234,9 +234,9 @@
234234
</template>
235235

236236
<template is="dom-if" if="[[showResetPW]]">
237-
<paper-button raised$="[[!flat]]" type="submit" on-click="_resetPassword" class="btn--resetpw" disabled$="[[_inProgress]]">
237+
<paper-button raised$="[[!flat]]" type="submit" on-click="_resetPassword" class="btn--resetpw" disabled$="[[inProgress]]">
238238
<span>[[localize('lf-resetpw-button')]]</span>
239-
<paper-progress class="btn-progress" hidden$="[[!_inProgress]]" disabled$="[[!_inProgress]]" indeterminate></paper-progress>
239+
<paper-progress class="btn-progress" hidden$="[[!inProgress]]" disabled$="[[!inProgress]]" indeterminate></paper-progress>
240240
</paper-button>
241241
<p>
242242
<paper-button class="link--reset-pw" on-click="toggleShowResetPW"
@@ -452,16 +452,16 @@
452452
this._cleanMessages();
453453
e = this.$$('#emailInput').validate()
454454
if (e) {
455-
this._inProgress = true;
455+
this._setInProgress(true);
456456
this.$$('#auth').auth.sendPasswordResetEmail(this.email)
457457
.then(function() {
458458
this.set('_lastMessage', this.localize('lf-resetpw-success-message'));
459459
}.bind(this), function(error) {
460460
this.set('_lastError', error.message);
461461
}.bind(this))
462462
.finally(function(){
463-
/* Set _inProgress back to false once everything is done */
464-
this._inProgress = false;
463+
/* Set inProgress back to false once everything is done */
464+
this._setInProgress(false);
465465
}.bind(this));
466466
}
467467
},

login-fire-social-behavior.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@
5353
*/
5454
signIn: function() {
5555
// Skip processing of this method when we already have started a sign or signout process
56-
if (this._inProgress) {
56+
if (this.inProgress) {
5757
if (this.debug) {
5858
console.log('Ignored signIn when already in progress');
5959
}
6060
return;
6161
}
6262
if (!this.noSignIn) {
63-
// Set _inProgress flag to true when a signin is started
64-
this._inProgress = true;
63+
// Set inProgress flag to true when a signin is started
64+
this._setInProgress(true);
6565
if (this.debug) {
6666
console.log('Signing in...');
6767
}

0 commit comments

Comments
 (0)