-
{userPlanets.length} {userPlanets.length > 0 ? 'Planets' : 'Planet'}
+
{userPlanets.length + user.Teams.reduce(function (sum, team) {
+ return sum + (team.Planets != null ? team.Planets.length : 0)
+ }, 0)} {userPlanets.length > 0 ? 'Planets' : 'Planet'}
{user.profileName}
{userPlanets}
+ {isOwner ? () : null}
{teamPlanets}
diff --git a/browser/main/Mixins/Helper.js b/browser/main/Mixins/Helper.js
new file mode 100644
index 00000000..fa8ec774
--- /dev/null
+++ b/browser/main/Mixins/Helper.js
@@ -0,0 +1,30 @@
+function deleteItemFromTargetArray (item, targetArray) {
+ targetArray.some(function (_item, index) {
+ if (_item.id === item.id) {
+ targetArray.splice(index, 1)
+ return true
+ }
+ return false
+ })
+
+ return targetArray
+}
+
+function updateItemToTargetArray (item, targetArray) {
+ var isNew = !targetArray.some(function (_item, index) {
+ if (_item.id === item.id) {
+ targetArray.splice(index, 1, item)
+ return true
+ }
+ return false
+ })
+
+ if (isNew) targetArray.push(item)
+
+ return targetArray
+}
+
+module.exports = {
+ deleteItemFromTargetArray: deleteItemFromTargetArray,
+ updateItemToTargetArray: updateItemToTargetArray
+}
diff --git a/browser/main/Stores/PlanetStore.js b/browser/main/Stores/PlanetStore.js
index 7cadc956..f7559876 100644
--- a/browser/main/Stores/PlanetStore.js
+++ b/browser/main/Stores/PlanetStore.js
@@ -4,6 +4,8 @@ var Reflux = require('reflux')
var UserStore = require('./UserStore')
+var Helper = require('../Mixins/Helper')
+
var actions = Reflux.createActions([
'update',
'destroy',
@@ -13,33 +15,8 @@ var actions = Reflux.createActions([
'destroyNote'
])
-function deleteItemFromTargetArray (item, targetArray) {
- targetArray.some(function (_item, index) {
- if (_item.id === item.id) {
- targetArray.splice(index, 1)
- return true
- }
- return false
- })
-
- return targetArray
-}
-
-function updateItemToTargetArray (item, targetArray) {
- var isNew = !targetArray.some(function (_item, index) {
- if (_item.id === item.id) {
- targetArray.splice(index, 1, item)
- return true
- }
- return false
- })
-
- if (isNew) targetArray.push(item)
-
- return targetArray
-}
-
module.exports = Reflux.createStore({
+ mixins: [Helper],
listenables: [actions],
Actions: actions,
onUpdate: function (planet) {
@@ -54,7 +31,7 @@ module.exports = Reflux.createStore({
var ownedByCurrentUser = currentUser.id === aPlanet.OwnerId
if (ownedByCurrentUser) {
- currentUser.Planets = updateItemToTargetArray(aPlanet, currentUser.Planets)
+ currentUser.Planets = this.updateItemToTargetArray(aPlanet, currentUser.Planets)
}
if (!ownedByCurrentUser) {
@@ -68,7 +45,7 @@ module.exports = Reflux.createStore({
})
if (team) {
- team.Planets = updateItemToTargetArray(aPlanet, team.Planets)
+ team.Planets = this.updateItemToTargetArray(aPlanet, team.Planets)
}
}
@@ -91,7 +68,7 @@ module.exports = Reflux.createStore({
var ownedByCurrentUser = currentUser.id === planet.OwnerId
if (ownedByCurrentUser) {
- currentUser.Planets = deleteItemFromTargetArray(planet, currentUser.Planets)
+ currentUser.Planets = this.deleteItemFromTargetArray(planet, currentUser.Planets)
}
if (!ownedByCurrentUser) {
@@ -105,7 +82,7 @@ module.exports = Reflux.createStore({
})
if (team) {
- team.Planets = deleteItemFromTargetArray(planet, team.Planets)
+ team.Planets = this.deleteItemFromTargetArray(planet, team.Planets)
}
}
@@ -126,7 +103,7 @@ module.exports = Reflux.createStore({
var planet = JSON.parse(localStorage.getItem('planet-' + code.PlanetId))
if (planet != null) {
- planet.Codes = updateItemToTargetArray(code, planet.Codes)
+ planet.Codes = this.updateItemToTargetArray(code, planet.Codes)
localStorage.setItem('planet-' + code.PlanetId, JSON.stringify(planet))
}
@@ -139,7 +116,7 @@ module.exports = Reflux.createStore({
onDestroyCode: function (code) {
var planet = JSON.parse(localStorage.getItem('planet-' + code.PlanetId))
if (planet != null) {
- planet.Codes = deleteItemFromTargetArray(code, planet.Codes)
+ planet.Codes = this.deleteItemFromTargetArray(code, planet.Codes)
localStorage.setItem('planet-' + code.PlanetId, JSON.stringify(planet))
}
@@ -155,7 +132,7 @@ module.exports = Reflux.createStore({
var planet = JSON.parse(localStorage.getItem('planet-' + note.PlanetId))
if (planet != null) {
- planet.Notes = updateItemToTargetArray(note, planet.Notes)
+ planet.Notes = this.updateItemToTargetArray(note, planet.Notes)
localStorage.setItem('planet-' + note.PlanetId, JSON.stringify(planet))
}
@@ -168,7 +145,7 @@ module.exports = Reflux.createStore({
onDestroyNote: function (note) {
var planet = JSON.parse(localStorage.getItem('planet-' + note.PlanetId))
if (planet != null) {
- planet.Notes = deleteItemFromTargetArray(note, planet.Notes)
+ planet.Notes = this.deleteItemFromTargetArray(note, planet.Notes)
localStorage.setItem('planet-' + note.PlanetId, JSON.stringify(planet))
}
diff --git a/browser/main/Stores/UserStore.js b/browser/main/Stores/UserStore.js
index b565716b..1a85440a 100644
--- a/browser/main/Stores/UserStore.js
+++ b/browser/main/Stores/UserStore.js
@@ -1,3 +1,5 @@
+/* global localStorage */
+
var Reflux = require('reflux')
var actions = Reflux.createActions([
@@ -8,6 +10,36 @@ var actions = Reflux.createActions([
module.exports = Reflux.createStore({
listenables: [actions],
onUpdate: function (user) {
+ var currentUser = JSON.parse(localStorage.getItem('currentUser'))
+
+ if (currentUser.id === user.id) {
+ localStorage.setItem('currentUser', JSON.stringify(user))
+ }
+
+ if (user.userType === 'team') {
+ var isMyTeam = user.Members.some(function (member) {
+ if (currentUser.id === member.id) {
+ return true
+ }
+ return false
+ })
+
+ if (isMyTeam) {
+ var isNew = !currentUser.Teams.some(function (team, index) {
+ if (user.id === team.id) {
+ currentUser.Teams.splice(index, 1, user)
+ return true
+ }
+ return false
+ })
+
+ if (isNew) {
+ currentUser.Teams.push(user)
+ }
+ localStorage.setItem('currentUser', JSON.stringify(currentUser))
+ }
+ }
+
this.trigger({
status: 'userUpdated',
data: user
diff --git a/browser/styles/main/containers/LoginContainer.styl b/browser/styles/main/containers/LoginContainer.styl
index 5af8e1f0..c190cf44 100644
--- a/browser/styles/main/containers/LoginContainer.styl
+++ b/browser/styles/main/containers/LoginContainer.styl
@@ -9,7 +9,7 @@
display block
margin 0 auto
.authNavigator
- margin 15px 0
+ margin 15px 0 25px
a
font-size 1.5em
text-decoration none
@@ -47,7 +47,8 @@
.dividerLabel
text-align center
position relative
- top -35px
+ top -27px
+ font-size 1.3em
background-color backgroundColor
margin 0 auto
width 50px
diff --git a/browser/styles/main/containers/UserContainer.styl b/browser/styles/main/containers/UserContainer.styl
index 733b8e25..1e5a8e8a 100644
--- a/browser/styles/main/containers/UserContainer.styl
+++ b/browser/styles/main/containers/UserContainer.styl
@@ -166,6 +166,23 @@
border-color darken(brandBorderColor, 10%)
background-color brandColor
color white
+ .newPlanetTooltip
+ position fixed
+ z-index 500
+ background-color transparentify(invBackgroundColor, 80%)
+ color invTextColor
+ padding 10px
+ line-height 1em
+ border-radius 5px
+ margin-top -23px
+ margin-left 33px
+ white-space nowrap
+ font-size 1.1em
+ opacity 0
+ transition 0.1s
+ pointer-events none
+ &:hover .newPlanetTooltip
+ opacity 1
.UserContainer
absolute top bottom right
left 55px
@@ -208,6 +225,13 @@
li
margin-bottom 10px
font-size 1.1em
+ .createTeamButton, .addMemberButton
+ btnStripDefault()
+ .members .role
+ margin-left 7px
+ margin-top 2px
+ color inactiveTextColor
+ font-size 0.85em
.planetList
absolute right bottom
top 125px
@@ -226,3 +250,5 @@
margin-left 15px
li
margin-bottom 10px
+ .createPlanetButton
+ btnStripDefault()
diff --git a/browser/styles/main/containers/UserSettingContainer.styl b/browser/styles/main/containers/UserSettingContainer.styl
deleted file mode 100644
index 31014ed9..00000000
--- a/browser/styles/main/containers/UserSettingContainer.styl
+++ /dev/null
@@ -1,33 +0,0 @@
-.UserSettingContainer
- absolute top bottom right
- left 50px
- .UserSettingNavigation
- absolute top bottom left
- width 200px
- padding 15px
- box-sizing border-box
- border-right solid 1px borderColor
- .userName
- font-size 2.0em
- margin 10px 0
- color brandColor
- a
- display block
- color textColor
- width 100%
- padding 15px
- margin-bottom 5px
- border-radius 10px
- box-sizing border-box
- cursor pointer
- &:hover, &.hover
- color brandColor
- background-color hoverBackgroundColor
- &:active, &.active
- color brandColor
-
- .UserSettingMain
- absolute top bottom right
- left 200px
- padding 10px
- box-sizing border-box
diff --git a/browser/styles/shared/modal.styl b/browser/styles/shared/modal.styl
index 92e601a3..c9bc6325 100644
--- a/browser/styles/shared/modal.styl
+++ b/browser/styles/shared/modal.styl
@@ -58,7 +58,7 @@
padding 15px
.EditProfileModal, .PlanetSettingModal
- .userInfoTab, .paswordTab, .planetProfileTab
+ .userInfoTab, .passwordTab, .planetProfileTab, .userInfoTab, .membersTab
padding-top 45px
.formField
position relative