Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 60 additions & 0 deletions app/elements/common/data-providers/user/user-search-provider.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<link rel="import" href="/bower_components/iron-ajax/iron-ajax.html">

<dom-module id="user-search-provider">
<style>
:host {
display: none;
}
</style>
<template>
<iron-ajax
id="request"
auto
method="GET"
url="{{url}}"
handle-as="json"
last-response="{{data}}"
with-credentials="true">
</iron-ajax>
</template>
<script type="application/javascript" src="/scripts/behaviors/providers/general-provider-behavior.js"></script>
<script type="application/javascript" src="/scripts/behaviors/providers/user-provider-behavior.js"></script>
<script>
Polymer({
is: 'user-search-provider',
properties: {
searchString: {
type: String,
notify: true,
observer: '_searchPropertyChanged'
}
},
behaviors: [
Behaviors.Providers.General,
Behaviors.Providers.User
],
observers: [
'_dataLoaded(data)'
],
_searchPropertyChanged: function(){
if (!!this.searchString && this.searchString.length > 2){
Copy link
Contributor

Choose a reason for hiding this comment

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

raise min length to 4

this.url = this.baseUrl + '/users/search?searchValue=' + this.searchString;
}
},
_dataLoaded: function(data){
for (var i = 0; i < data.length; i++){
data[i].label = this._getUserLabel(data[i]);
}
},
_getUserLabel: function(user){
if (!user){
return '';
}
var label = this._getFullName(user);
label = label === '' ? user.username : label + ' - ' + user.username;
label = label + ' - ' + user.email;
return label;
}
});
</script>
</dom-module>
48 changes: 32 additions & 16 deletions app/elements/company/candidate/invite/invite-candidate-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
<link rel="import" href="/bower_components/paper-item/paper-item.html">
<link rel="import" href="/bower_components/iron-flex-layout/iron-flex-layout-classes.html">

<link rel="import" href="/bower_components/vaadin-combo-box/vaadin-combo-box.html">
<link rel="import" href="/elements/common/data-providers/user/user-search-provider.html">

<dom-module id="invite-candidate-input">
<style include="iron-flex">
:host {
display: block;
}
#address {
width: 325px;
width: 100%;
@apply(--layout-self-center);
}

Expand All @@ -26,16 +29,20 @@
}
</style>
<template>
<user-search-provider search-string="[[inputValue]]" data="{{users}}"></user-search-provider>
<div id="row">
<paper-input
<vaadin-combo-box
id="address"
label="person@example.com"
value="{{candidate.email}}"
type="email"
error-message="Address should match the example above"
required>
</paper-input>
<iron-icon icon="remove" on-click="_removeItem"></iron-icon>
value="{{email}}"
item-label-path="label"
item-value-path="email"
on-input-value-changed="_inputValueChanged"
allow-custom-value
items="[[users]]">
</vaadin-combo-box>
<template is="dom-if" if="{{removable}}">
<iron-icon icon="remove" on-click="_removeItem"></iron-icon>
</template>
</div>
</template>
<script>
Expand All @@ -46,18 +53,27 @@
Polymer.IronValidatableBehavior
],
properties: {
candidate: {
type: Object,
reflectToAttribute: true,
email: {
notify: true
},
inputValue: {
notify: true
},
removable: {
type: Boolean,
notify: true
}

},
validate: function(){
return this.$.address.validate();
_inputValueChanged: function(e){
this.inputValue = e.detail;
this.email = e.detail;
if (!!this.inputValue && this.inputValue.length < 3){
this.users = [];
}
},
_removeItem: function () {
this.fire('candidate-removed', this.candidate);
this.remove();
this.fire('candidate-removed', this.email);
}
});
</script>
Expand Down
72 changes: 28 additions & 44 deletions app/elements/company/candidate/invite/invite-candidates.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,81 @@
<link rel="import" href="/elements/common/services/user-service.html">

<link rel="import" href="/bower_components/paper-button/paper-button.html">
<link rel="import" href="/bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="/bower_components/paper-material/paper-material.html">
<link rel="import" href="/bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
<link rel="import" href="/bower_components/iron-form/iron-form.html">
<link rel="import" href="/bower_components/paper-toast/paper-toast.html">
<link rel="import" href="/bower_components/iron-flex-layout/iron-flex-layout-classes.html">

<dom-module id="invite-candidates">
<style>
.buttonGroup {
<style include="iron-flex">
.button-group {
@apply(--layout-horizontal-reverse);
margin: 16px;
float: right;
}

#addCandidate {
margin-top: 10px;
cursor: pointer;
}

#dialog {
position: fixed;
top: 10%;
}
paper-dialog-scrollable {
height: 100%;
}
</style>
<template>
<user-service id="userService"></user-service>

<paper-dialog id="dialog" modal style="background: white;">
<h2>Invite candidates</h2>

<p>The address format must be: Name (first and last name or a combination) &lt;email address&gt;</p>
<paper-dialog-scrollable>
<form is="iron-form" id="form">
<template is="dom-repeat" items="{{candidates}}">
<invite-candidate-input name="inviteCandidateInput" candidate="{{item}}" required></invite-candidate-input>
</template>

</form>
</paper-dialog-scrollable>
<p>Start typing the candidates email address</p>
<form is="iron-form" id="form">
<template is="dom-repeat" items="{{candidates}}">
<invite-candidate-input name="inviteCandidateInput" email="{{item}}" required removable="{{multi}}"></invite-candidate-input>
</template>
</form>
<template is="dom-if" if="{{multi}}">
<div id="addCandidate" on-click="_addCandidate">
<iron-icon icon="add"></iron-icon>
<span>Add another candidate</span>
</div>
<div class="buttonGroup">
<paper-button class="primary" dialog-dismiss>Cancel</paper-button>
<paper-button class="primary" raised on-click="inviteCandidates">Invite
</paper-button>
</div>

</paper-dialog>
<paper-toast id="toast" text="Candidates invited."></paper-toast>
<iron-icon icon="add"></iron-icon>
<span>Add another candidate</span>
</div>
</template>
<div class="button-group">
<paper-button id="inviteButton" class="primary" raised on-click="inviteCandidates">Invite</paper-button>
</div>
</template>
<script>
Polymer({
is: 'invite-candidates',
properties: {
challenge: {
type: Object,
challengeId: {
notify: true
},
candidates: {
type: Array,
notify: true,
value: []
},
multi: {
type: Boolean,
value: false
}
},
listeners: {
'candidate-removed': '_removeCandidate',
'user-invited': '_userInvited'
},
toggle: function () {
reset: function(){
this._clearCandidates();
this._addCandidate();
this.$.dialog.toggle();
},
inviteCandidates: function () {
if (!this.$.form.validate()){
return;
}
for (var i = 0; i < this.candidates.length; i++) {
this.$.userService.invite({
'email': this.candidates[i].email,
'challengeId': this.candidates[i].challengeId
'email': this.candidates[i],
'challengeId': this.challengeId
});
}
this.$.dialog.close();
},
_addCandidate: function () {
this.push('candidates', {'challengeId': this.challenge.id});
this.push('candidates', '');
},
_removeCandidate: function(event){
var index = this.candidates.indexOf(event.detail);
Expand All @@ -101,7 +86,6 @@ <h2>Invite candidates</h2>
this.candidates = [];
},
_userInvited: function(){
this.$.toast.show();
this.fire('invitation-sent');
}
});
Expand Down
42 changes: 29 additions & 13 deletions app/elements/company/challenge/challenge-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,21 @@
#wrapper {
@apply(--layout-vertical);
}
#inviteWrapper {
.layout-horizontal {
@apply(--layout-horizontal);
}
#challengeName {

.flex {
@apply(--layout-flex);
}
</style>
<template>
<challenge-service id="challengeService" challenge="{{challenge}}"></challenge-service>
<invitation-service id="invitationService" invitations="{{invitations}}"></invitation-service>
<invite-candidates id="inviteCandidates" challenge="{{challenge}}" on-invitation-sent="_onInvitationSent"></invite-candidates>

<div id="wrapper" class="grid mainContent">
<paper-material class="card" elevation="1">
<div id="inviteWrapper">
<h1 id="challengeName">{{challenge.name}}</h1>
<paper-button on-click="_inviteCandidates">
<iron-icon icon="mail"></iron-icon>
Invite candidates
</paper-button>
</div>
<h1>{{challenge.name}}</h1>
<description-list>
<description-list-item label="Canonical name" value="{{challenge.canonicalName}}"></description-list-item>
<description-list-item label="Start date" value="{{challenge.startDate}}" date></description-list-item>
Expand All @@ -60,7 +54,19 @@ <h1 id="challengeName">{{challenge.name}}</h1>
</paper-material>

<paper-material class="card">
<h3>Invited users</h3>
<div class="layout-horizontal">
<h3 class="flex">Invited users</h3>
<paper-button on-click="inviteCandidates">
<iron-icon icon="{{inviteIcon}}"></iron-icon>
Invite candidates
</paper-button>
</div>
<invite-candidates
id="inviteCandidates"
style="display: none"
Copy link
Contributor

Choose a reason for hiding this comment

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

inline style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i put inline style to avoid having another inviteCandidatesStyle property with default value.

challenge-id="{{challenge.id}}"
on-invitation-sent="_onInvitationSent">
</invite-candidates>
<table style="width:100%">
<tr>
<th>Username</th>
Expand Down Expand Up @@ -107,6 +113,7 @@ <h3>Invited users</h3>
},
_challengeIdChanged: function(){
this._refresh();
this.inviteIcon = 'add';
},
_refresh: function(){
this.$.challengeService.getById(this.challengeId);
Expand All @@ -117,10 +124,19 @@ <h3>Invited users</h3>
return util.formatDate(date);
}
},
_inviteCandidates: function(){
this.$.inviteCandidates.toggle();
inviteCandidates: function(){
if (!this.showInvitation){
this.inviteIcon = 'remove';
this.$.inviteCandidates.style.display = '';
this.$.inviteCandidates.reset();
}else{
this.inviteIcon = 'add';
this.$.inviteCandidates.style.display = 'none';
}
this.showInvitation = !this.showInvitation;
},
_onInvitationSent: function(){
this.$.inviteCandidates.reset();
this._refresh();
}
});
Expand Down
4 changes: 1 addition & 3 deletions app/elements/company/challenge/challenge-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h4>Challenges for this template</h4>
New challenge
</paper-button>
</paper-material>
<invite-candidates id="inviteCandidatesModal"></invite-candidates>
</template>
<script>
Polymer({
Expand All @@ -62,8 +61,7 @@ <h4>Challenges for this template</h4>
page('/challenge/template/'+ this.challengeTemplate.id + '/create');
},
_inviteCandidates: function (e) {
this.$.inviteCandidatesModal.challenge = e.model.__data__.item;
this.$.inviteCandidatesModal.toggle();
page('/challenges/' + e.model.__data__.item.id + '?invite=true');
},
_formatDate: function(date){
if (!!date){
Expand Down
Loading