V3-1029 Update list Project Logic (#966)

This commit is contained in:
Yehor Butko 2019-01-04 13:32:21 +02:00 committed by GitHub
parent c0e6b62708
commit 262753bde6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -46,6 +46,7 @@ read all (
select project
join project.id = project_member.project_id
where project_member.member_id = ?
orderby asc project.name
)
create project ( )
update project ( where project.id = ? )

View File

@ -1167,11 +1167,11 @@ func (obj *sqlite3Impl) Get_Project_By_Id(ctx context.Context,
}
func (obj *sqlite3Impl) All_Project_By_ProjectMember_MemberId(ctx context.Context,
func (obj *sqlite3Impl) All_Project_By_ProjectMember_MemberId_OrderBy_Asc_Project_Name(ctx context.Context,
project_member_member_id ProjectMember_MemberId_Field) (
rows []*Project, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT projects.id, projects.name, projects.description, projects.terms_accepted, projects.created_at FROM projects JOIN project_members ON projects.id = project_members.project_id WHERE project_members.member_id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT projects.id, projects.name, projects.description, projects.terms_accepted, projects.created_at FROM projects JOIN project_members ON projects.id = project_members.project_id WHERE project_members.member_id = ? ORDER BY projects.name")
var __values []interface{}
__values = append(__values, project_member_member_id.value())
@ -1804,14 +1804,14 @@ func (rx *Rx) All_ProjectMember_By_MemberId(ctx context.Context,
return tx.All_ProjectMember_By_MemberId(ctx, project_member_member_id)
}
func (rx *Rx) All_Project_By_ProjectMember_MemberId(ctx context.Context,
func (rx *Rx) All_Project_By_ProjectMember_MemberId_OrderBy_Asc_Project_Name(ctx context.Context,
project_member_member_id ProjectMember_MemberId_Field) (
rows []*Project, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.All_Project_By_ProjectMember_MemberId(ctx, project_member_member_id)
return tx.All_Project_By_ProjectMember_MemberId_OrderBy_Asc_Project_Name(ctx, project_member_member_id)
}
func (rx *Rx) Create_ApiKey(ctx context.Context,
@ -2006,7 +2006,7 @@ type Methods interface {
project_member_member_id ProjectMember_MemberId_Field) (
rows []*ProjectMember, err error)
All_Project_By_ProjectMember_MemberId(ctx context.Context,
All_Project_By_ProjectMember_MemberId_OrderBy_Asc_Project_Name(ctx context.Context,
project_member_member_id ProjectMember_MemberId_Field) (
rows []*Project, err error)

View File

@ -31,7 +31,7 @@ func (projects *projects) GetAll(ctx context.Context) ([]satellite.Project, erro
// GetByUserID is a method for querying all projects from the database by userID.
func (projects *projects) GetByUserID(ctx context.Context, userID uuid.UUID) ([]satellite.Project, error) {
projectsDbx, err := projects.db.All_Project_By_ProjectMember_MemberId(ctx, dbx.ProjectMember_MemberId(userID[:]))
projectsDbx, err := projects.db.All_Project_By_ProjectMember_MemberId_OrderBy_Asc_Project_Name(ctx, dbx.ProjectMember_MemberId(userID[:]))
if err != nil {
return nil, err
}

View File

@ -21,17 +21,22 @@ import { removeToken } from '@/utils/tokenManager';
@Component({
beforeMount: async function() {
// TODO: should place here some animation while all needed data is fetching
let response: RequestResponse<User> = await this.$store.dispatch('getUser');
if (response.isSuccess) {
if (!response.isSuccess) {
this.$store.dispatch('error', response.errorMessage);
this.$router.push('/login');
removeToken();
return;
}
this.$store.dispatch('error', response.errorMessage);
this.$router.push('/login');
removeToken();
let getProjectsResponse: RequestResponse<Project[]> = await this.$store.dispatch('fetchProjects');
if (getProjectsResponse.isSuccess && getProjectsResponse.data.length > 0) {
this.$store.dispatch('selectProject', getProjectsResponse.data[0].id);
}
},
components: {
NavigationArea,