Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSK-943:General Status support #2842

Merged
merged 11 commits into from
Apr 4, 2023
Merged

TSK-943:General Status support #2842

merged 11 commits into from
Apr 4, 2023

Conversation

haiodo
Copy link
Member

@haiodo haiodo commented Mar 27, 2023

Contribution checklist

Brief description

Overview of current Status like properties.

class Issue {
 space: Ref<Project>
 status: Status  // (leave in Project space, attached to status attribute)
 
 verification: Status // Potential verification like (Unverified/In progress/Verified/Reopened)
}
 
// HR
class Vacancy extend Space {
  // User could add custom status field.
 status: Status (leave in Vacancy space, attached to status attribute) // We do not have it right now.
}
 
class DoneState extend Status {
}
class WonState extends DoneState {}
class LoseState extends DoneState {}

// Alternative

 
class Application {
 status: Status // Original state per Vacancy.
 doneStatus: DoneState // Custom editor to distuinguish states.
}

// Leads

Example Instances

// We create a system public space to hold all system statuses
instance: Project1 {
  issueBacklog: Status ('Backlog') // (Issue.status)
  issueTodo: Status('Todo') // (Issue.status)
  issueInProgress: Status('In progress') // (Issue.status)
  issueDone: Status('Done') // (Issue.status)
 
  issue1: Issue(status: issueTodo, priority: priHigh)
  issue2: Issue(status: issueInProgress, priority: priLow)
}

instance: Project2 {
  // Same set as in Project1
  // …
  //
  issueCanceled: Status(Issue.status) // (new)
 
 
  Issue3: Issue(status: issueDone, priority: priHigh)
  Issue4: Issue(status: issueCanceled, priority: priNone)
  Issue5: Issue(status: issueTodo, priority: priUrgent)
}
  

How Search is working

client.findAll(tracker.class.Issue, {status: project1.issueTodo}, {sorting: { priority: Descending }})

=> Should return by status from project1 and all similar named statues from project2.

Title Status(ID) Priority⬇︎
Issue5 Todo (proj2.issueTodo) Urgent (prj2.priorityUrgent)
Issue1 Todo (prj1.issueTodo) High (prj1.priorityHigh)

And if we need to use status only from set of spaces.

client.findAll(Issue, {status: project1.Todo, project: project1._id })

How it work underline:

  1. Server is holding a mapping for every status based attribute byId and with titleToStatus = Map<string/title/, Ref[]>.
  2. When find is executed, if status field are used, we replace it with {$in: titletoStatus[statusTitle] }

So all queries will properly work.

How sorting is working

Sorting are performed undeline by following criterias:

if query options has sorting: {status: Order}

  1. Field is mapped to

  2. If category is defined for status, status are sorted by category order.

  3. Sorting status by rank (inside category first).

  const statuses = sortedStatuses.filter(it => it.title==titleStatus).map((value, index) => {
    return { case: { $eq: [`$${key}`, value] }, then: index }
  })
  pipeline.push({
    $addFields: {
      [`sort_${key}`]: {
        $switch: {
          branches,
          default: statuses.length
        }
      }
    }
  })
  sort[`sort_${key}`] = options.sort[_key] === SortingOrder.Ascending ? 1 : -1

Status category mapping, for Lists and Kanbans

View package has getCategories(_class, docs, key, viewlet) -> any[] it return all categories for key, and sort them as desider for viewlet.
It is used by List and Kanban components.

So we will extend it for status based attributes to return

interface StatusValue {
    name: string
    color?: string
    value: Ref<Status>[] // Real status items per category.
}

Status presenter will be updated to support StatusValue display.

Additional methods will be added to view

function groupByStatusName(status: Status[]): (StatusMultiValue|Status)[]

It will group by title identity for same status values.

How we search for Status to display in filters, dropdowns etc.

client.findAll(core.clsss.Status, { ofAttribute: tracker.attrubute.IssueStatus })
client.findAll(core.clsss.Status, { ofAttribute: tracker.attrubute.IssueStatus, space: {$in: [projec1, project2]} })

So it should return

Title _id
Backlogproj1.issueBacklog
Backlogproj2.issueBacklog
Todoproj1.issueTodo
Todoproj2.issueTodo
In progressproj1.issueInProgress
In progressproj2.issueInProgress
Doneproj1.issueDone
Doneproj2.issueDone

ObjectFilter will use groupByStatus

Code core

/**
    @public
 */
export interface StatusCategory extends Doc {
  ofAttribute: Ref<Attribute<Status>>
  
  icon: Asset
  label: IntlString
  color: number
  // Name for default status for auto create per space
  defaultStatusName?: string
  order: number // category order
}

/**
    @public
 */
export interface Status extends Doc {
  // We attach to attribute, so we could distinguish between
  ofAttribute: Ref<Attribute<Status>>

  // Optional category.
  category?: Ref<StatusCategory>

  // Status with case insensitivity name match will be assumed same.
  name: string

  // Optional color
  color?: number
  // Optional description
  description?: string
  // Lexorank rank for ordering.
  rank: string
}

/**
* @public
*/
interface StatusValue {
    name: string
    color?: string
    value: Ref<Status>[] // Real status items per category.
}

All status documents live in status domain, so migration will move them into this one unified place.

Checklist

  • - UI test added to added/changed functionality?
  • - Screenshot is added to PR if applicable ?
  • - Does the code work? Check whether function and logic are correct.
  • - Does Changelog.md is updated with changes?
  • - Does the translations are up to date?
  • - Does it well tested?
  • - Tested for Chrome.
  • - Tested for Safari.
  • - Go through the changed code looking for typos, TODOs, commented LOCs, debugging pieces of code, etc.
  • - Rebase your branch onto master and upstream branch
  • - Is there any redundant or duplicate code?
  • - Are required links are linked to PR?
  • - Does new code is well documented ?

Related issues

A list of closed updated issues

@haiodo haiodo changed the title TSK-955: Fix status display (#2840) TSK-943:General Status support Mar 28, 2023
@haiodo haiodo force-pushed the TSK-943 branch 6 times, most recently from 86cadc8 to f177c85 Compare April 3, 2023 06:19
@haiodo haiodo marked this pull request as ready for review April 3, 2023 06:19
@haiodo haiodo force-pushed the TSK-943 branch 6 times, most recently from 7c80a6b to 441bb98 Compare April 3, 2023 19:06
@haiodo haiodo requested a review from BykhovDenis April 3, 2023 19:38
haiodo added 11 commits April 4, 2023 12:20
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
@haiodo haiodo merged commit 585d823 into main Apr 4, 2023
@haiodo haiodo deleted the TSK-943 branch April 4, 2023 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants