projects
/
osm
/
UI.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow upload/update through session manager
[osm/UI.git]
/
skyquake
/
plugins
/
project_management
/
src
/
dashboard
/
dashboard.jsx
diff --git
a/skyquake/plugins/project_management/src/dashboard/dashboard.jsx
b/skyquake/plugins/project_management/src/dashboard/dashboard.jsx
index
f1fca65
..
66c3f48
100644
(file)
--- a/
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
+++ b/
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
@@
-20,7
+20,7
@@
import SelectOption from 'widgets/form_controls/selectOption.jsx';
import 'widgets/form_controls/formControls.scss';
import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
import imgRemove from '../../node_modules/open-iconic/svg/trash.svg'
import 'widgets/form_controls/formControls.scss';
import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
import imgRemove from '../../node_modules/open-iconic/svg/trash.svg'
-
+import _ from 'lodash';
import ROLES from 'utils/roleConstants.js';
const PROJECT_ROLES = ROLES.PROJECT;
const PLATFORM = ROLES.PLATFORM;
import ROLES from 'utils/roleConstants.js';
const PROJECT_ROLES = ROLES.PROJECT;
const PLATFORM = ROLES.PLATFORM;
@@
-76,7
+76,7
@@
class ProjectManagementDashboard extends React.Component {
this.actions.handleAddProject();
}
viewProject = (un, index) => {
this.actions.handleAddProject();
}
viewProject = (un, index) => {
- this.actions.viewProject(un, index);
+ this.actions.viewProject(un, index
, true
);
}
editProject = () => {
this.actions.editProject(false);
}
editProject = () => {
this.actions.editProject(false);
@@
-91,9
+91,11
@@
class ProjectManagementDashboard extends React.Component {
deleteProject = (e) => {
e.preventDefault();
e.stopPropagation();
deleteProject = (e) => {
e.preventDefault();
e.stopPropagation();
- this.Store.deleteProject({
+ if (confirm('Are you sure you want to delete this project?')) {
+ this.Store.deleteProject({
'name': this.state['name']
});
'name': this.state['name']
});
+ }
}
createProject = (e) => {
let self = this;
}
createProject = (e) => {
let self = this;
@@
-116,36
+118,44
@@
class ProjectManagementDashboard extends React.Component {
let self = this;
e.preventDefault();
e.stopPropagation();
let self = this;
e.preventDefault();
e.stopPropagation();
-
let projectName = self.state['name'];
- let projectUsers =
self.state.projectUsers
;
+ let projectName = self.state['name'];
+ let projectUsers =
_.cloneDeep(self.state.projectUsers)
;
let cleanUsers = this.cleanUsers(projectUsers, projectName);
let cleanUsers = this.cleanUsers(projectUsers, projectName);
- this.Store.updateProject(
_.merge(
{
+ this.Store.updateProject({
'name': projectName,
'description': self.state.description,
'project-config' : {
'user': cleanUsers
}
'name': projectName,
'description': self.state.description,
'project-config' : {
'user': cleanUsers
}
- })
)
;
+ });
}
cleanUsers(projectUsers, projectName) {
}
cleanUsers(projectUsers, projectName) {
+ let self = this;
let cleanUsers = [];
//Remove null values from role
projectUsers.map((u) => {
let cleanRoles = [];
let cleanUsers = [];
//Remove null values from role
projectUsers.map((u) => {
let cleanRoles = [];
+ let cleanManoRoles = [];
u.role && u.role.map((r,i) => {
let role = {};
//you may add a user without a role or a keys, but if one is present then the other must be as well.
u.role && u.role.map((r,i) => {
let role = {};
//you may add a user without a role or a keys, but if one is present then the other must be as well.
- if(!r.role ) {
- } else {
+ if(r.role) {
delete r.keys;
delete r.keys;
- // r.keys = projectName;
- cleanRoles.push(r)
+ // r.keys = projectName;
+ switch(ROLES.PROJECT.TYPE[r.role]) {
+ case 'rw-project-mano' : cleanManoRoles.push(r); break;
+ case 'rw-project' : cleanRoles.push(r); break;
+ }
}
});
u.role = cleanRoles;
}
});
u.role = cleanRoles;
- cleanUsers.push(u);
+ u["rw-project-mano:mano-role"] = u["rw-project-mano:mano-role"] || [];
+ u["rw-project-mano:mano-role"] = u["rw-project-mano:mano-role"].concat(cleanManoRoles);
+ if (u['user-name'] != self.context.userProfile.userId) {
+ cleanUsers.push(u);
+ }
});
return cleanUsers;
}
});
return cleanUsers;
}
@@
-173,13
+183,6
@@
class ProjectManagementDashboard extends React.Component {
removeUserFromProject = (userIndex, e) => {
this.actions.handleRemoveUserFromProject(userIndex);
}
removeUserFromProject = (userIndex, e) => {
this.actions.handleRemoveUserFromProject(userIndex);
}
- updateUserRoleInProject = (userIndex, roleIndex, e) => {
- this.actions.handleUpdateUserRoleInProject({
- userIndex,
- roleIndex,
- value: JSON.parse(e.target.value)
- })
- }
toggleUserRoleInProject = (userIndex, roleIndex, e) => {
this.actions.handleToggleUserRoleInProject({
userIndex,
toggleUserRoleInProject = (userIndex, roleIndex, e) => {
this.actions.handleToggleUserRoleInProject({
userIndex,
@@
-323,9
+326,13
@@
class ProjectManagementDashboard extends React.Component {
<tbody>
{
state.projectUsers.map((u,i)=> {
<tbody>
{
state.projectUsers.map((u,i)=> {
- let userRoles = u.role && u.role.map((r) => {
- return r.role;
- }) || [];
+ let userRoles = []
+ u.role && u.role.map((r) => {
+ userRoles.push(r.role);
+ });
+ u["rw-project-mano:mano-role"] && u["rw-project-mano:mano-role"].map((r) => {
+ userRoles.push(r.role);
+ });
return (
<tr key={i}>
{!state.isReadOnly ? <td><span
return (
<tr key={i}>
{!state.isReadOnly ? <td><span
@@
-386,7
+393,8
@@
class ProjectManagementDashboard extends React.Component {
}
// onClick={this.Store.update.bind(null, Account)}
ProjectManagementDashboard.contextTypes = {
}
// onClick={this.Store.update.bind(null, Account)}
ProjectManagementDashboard.contextTypes = {
- router: React.PropTypes.object
+ router: React.PropTypes.object,
+ userProfile: React.PropTypes.object
};
ProjectManagementDashboard.defaultProps = {
};
ProjectManagementDashboard.defaultProps = {