Skip to content

Commit

Permalink
Changed: Extract projectUsers form UserInput
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 12, 2024
1 parent 2257510 commit 966f835
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 42 deletions.
22 changes: 14 additions & 8 deletions src/components/ProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
<UserInput :project="project" :context="context"
:bridgeheads="visibleBridgeheads"
:todos="extendedExplanations"
:project-manager-backend-service="projectManagerBackendService"/>
:project-manager-backend-service="projectManagerBackendService"
:call-refreh-context="refreshContext"
:current-users="projectUsers"/>
</div>
</div>
<div class="data-container mt-12">
Expand Down Expand Up @@ -295,7 +297,7 @@ import {
ProjectManagerBackendService,
ProjectManagerContext,
ProjectRole,
Site
Site, User
} from "@/services/projectManagerBackendService";
import ProjectManagerButton from "@/components/ProjectManagerButton.vue";
import {format} from "date-fns";
Expand Down Expand Up @@ -384,7 +386,8 @@ export default defineComponent({
extendedExplanations: new Map() as Explanations,
buttonGroups: [] as boolean[],
isButtonGroupVisible: false,
actionButtons: [] as ActionButtonGroup[]
actionButtons: [] as ActionButtonGroup[],
projectUsers: [] as User[]
};
},
watch: {
Expand Down Expand Up @@ -540,13 +543,12 @@ export default defineComponent({
this.initializeData(Module.TOKEN_MANAGER_MODULE, Action.EXISTS_AUTHENTICATION_SCRIPT_ACTION, new Map(), 'existsAuthenticationScript');
this.initializeData(Module.USER_MODULE, Action.FETCH_PROJECT_ROLES_ACTION, new Map(), 'projectRoles');
this.initializeData(Module.USER_MODULE, Action.EXIST_INVITED_USERS_ACTION, new Map(), 'existInvitedUsers');
this.initializeData(Module.USER_MODULE, Action.FETCH_PROJECT_USERS_ACTION, new Map(), 'projectUsers');
this.initializeData(Module.EXPORT_MODULE, Action.ARE_EXPORT_FILES_TRANSFERRED_TO_RESEARCH_ENVIRONMENT_ACTION, new Map(), 'areExportFilesTransferredToResearchEnvironment');
this.explanations = this.projectManagerBackendService.fetchExplanations();
this.extendedExplanations = this.fetchExtendedExplanations();
setTimeout(() => {
this.getButtons()
this.checkButtonVisibility()
}, 1000);
this.fetchButtons()
this.checkButtonVisibility()
}
},
Expand Down Expand Up @@ -648,6 +650,9 @@ export default defineComponent({
this.removeActionExplanation(Action.SAVE_QUERY_IN_BRIDGEHEAD_ACTION, extendedExplanations);
this.removeActionExplanation(Action.SAVE_AND_EXECUTE_QUERY_IN_BRIDGEHEAD_ACTION, extendedExplanations);
this.removeActionExplanation(Action.SEND_EXPORT_FILES_TO_RESEARCH_ENVIRONMENT_ACTION, extendedExplanations);
this.removeActionExplanation(Action.SET_DEVELOPER_USER_ACTION, extendedExplanations);
this.removeActionExplanation(Action.SET_PILOT_USER_ACTION, extendedExplanations);
this.removeActionExplanation(Action.SET_FINAL_USER_ACTION, extendedExplanations);
}
if (this.existsDraftDialog) {
Expand Down Expand Up @@ -822,7 +827,7 @@ export default defineComponent({
] as ProjectField[]
},
getButtons(): void {
fetchButtons(): void {
this.actionButtons = [
{
label: "Project",
Expand Down Expand Up @@ -981,6 +986,7 @@ export default defineComponent({
}
}
});
Expand Down
43 changes: 11 additions & 32 deletions src/components/UserInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@ import {
Module,
Project,
ProjectManagerContext,
ProjectManagerBackendService, Explanations
ProjectManagerBackendService, Explanations, User
} from "@/services/projectManagerBackendService";
interface User {
email: string;
firstName: string | null;
lastName: string | null;
bridgehead: string;
humanReadableBridgehead: string | null;
projectRole: string;
projectState: string;
}
@Options({
name: "UserInput",
computed: {
Expand All @@ -35,12 +25,13 @@ export default class UserInput extends Vue {
@Prop() readonly project!: Project;
@Prop() readonly bridgeheads!: Bridgehead[];
@Prop() readonly todos?: Explanations;
@Prop() readonly currentUsers!: User[];
@Prop({type: Function, required: true}) readonly callRefrehContext!: () => void;
partialEmail = '';
selectedBridgehead: Bridgehead | undefined = undefined;
suggestions: User[] = [];
isActive = false;
currentUsers: User[] = [];
canInvite = true;
showSuggestions = false;
Expand All @@ -56,11 +47,8 @@ export default class UserInput extends Vue {
}
updateIsActive() {
this.projectManagerBackendService.isModuleActionActive(Module.USER_MODULE, Action.FETCH_USERS_FOR_AUTOCOMPLETE_ACTION).then(isActive => {
this.projectManagerBackendService.isModuleActionActive(Module.USER_MODULE, this.fetchAction()).then(isActive => {
this.isActive = isActive;
if (isActive) {
this.updateCurrentUsers();
}
});
}
Expand All @@ -75,19 +63,23 @@ export default class UserInput extends Vue {
this.autocomplete(this.partialEmail);
}
handleSave(): void {
fetchAction(): Action{
let action: Action = Action.SET_DEVELOPER_USER_ACTION;
if (this.project.state === 'PILOT') {
action = Action.SET_PILOT_USER_ACTION;
} else if (this.project.state === 'FINAL') {
action = Action.SET_FINAL_USER_ACTION;
}
return action;
}
handleSave(): void {
const params = new Map<string, string>();
params.set('email', this.partialEmail);
const context = (this.selectedBridgehead) ? this.createContext(this.selectedBridgehead) : this.context;
this.projectManagerBackendService.fetchData(Module.USER_MODULE, action, context, params).then(result => {
this.projectManagerBackendService.fetchData(Module.USER_MODULE, this.fetchAction(), context, params).then(result => {
this.partialEmail = '';
this.updateCurrentUsers();
this.callRefrehContext();
});
}
Expand All @@ -105,19 +97,6 @@ export default class UserInput extends Vue {
}
}
updateCurrentUsers() {
let index = 0;
this.bridgeheads.forEach(bridgehead => this.projectManagerBackendService
.fetchData(Module.USER_MODULE, Action.FETCH_PROJECT_USERS_ACTION, this.createContext(bridgehead), new Map())
.then(currentUsers => {
if (index == 0) {
this.currentUsers = [];
}
index += 1;
this.currentUsers.push(...currentUsers)
}));
}
createContext(bridgehead: Bridgehead | undefined) {
return (bridgehead) ? new ProjectManagerContext(this.context.projectCode, bridgehead) : this.context;
}
Expand Down
13 changes: 11 additions & 2 deletions src/services/projectManagerBackendService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ export interface Notification {
read: boolean | null;
}

export interface User {
email: string;
firstName: string | null;
lastName: string | null;
bridgehead: string;
humanReadableBridgehead: string | null;
projectRole: string;
projectState: string;
}


export interface Bridgehead {
projectCode: string;
bridgehead: string;
Expand Down Expand Up @@ -220,12 +231,10 @@ export interface ActionButtonGroup {
export interface ActionButton {
module: Module
action: Action
//context: ProjectManagerContext
refreshContextCallFunction: () => void
text: string
withMessage: boolean
cssClass: string
//pmbs: ProjectManagerBackendService
visibilityCondition?: boolean
}

Expand Down

0 comments on commit 966f835

Please sign in to comment.