diff --git a/modules/dop/component-protocol/components/issue-gantt/filter/model.go b/modules/dop/component-protocol/components/issue-gantt/filter/model.go index 0495b07980c..789cfc0dcf1 100644 --- a/modules/dop/component-protocol/components/issue-gantt/filter/model.go +++ b/modules/dop/component-protocol/components/issue-gantt/filter/model.go @@ -31,14 +31,16 @@ type ComponentFilter struct { State State `json:"state,omitempty"` base.DefaultProvider - projectID uint64 `json:"-"` - Iterations []apistructs.Iteration `json:"-"` - Members []apistructs.Member `json:"-"` + FrontendUrlQuery string `json:"-"` + projectID uint64 `json:"-"` + Iterations []apistructs.Iteration `json:"-"` + Members []apistructs.Member `json:"-"` } type State struct { - Conditions []filter.PropCondition `json:"conditions,omitempty"` - Values FrontendConditions `json:"values,omitempty"` + Base64UrlQueryParams string `json:"filter__urlQuery,omitempty"` + Conditions []filter.PropCondition `json:"conditions,omitempty"` + Values FrontendConditions `json:"values,omitempty"` } type FrontendConditions struct { diff --git a/modules/dop/component-protocol/components/issue-gantt/filter/render.go b/modules/dop/component-protocol/components/issue-gantt/filter/render.go index ee796730248..e95b7cf3248 100644 --- a/modules/dop/component-protocol/components/issue-gantt/filter/render.go +++ b/modules/dop/component-protocol/components/issue-gantt/filter/render.go @@ -16,6 +16,8 @@ package filter import ( "context" + "encoding/base64" + "encoding/json" "strconv" "time" @@ -44,6 +46,10 @@ func (f *ComponentFilter) Render(ctx context.Context, c *cptype.Component, scena return err } f.projectID = projectID + if q := cputil.GetInParamByKey(ctx, "filter__urlQuery"); q != nil { + f.FrontendUrlQuery = q.(string) + } + iterations, iterationOptions, err := f.getPropIterationsOptions() if err != nil { return err @@ -58,7 +64,7 @@ func (f *ComponentFilter) Render(ctx context.Context, c *cptype.Component, scena } switch event.Operation { - case cptype.InitializeOperation: + case cptype.InitializeOperation, cptype.RenderingOperation: f.Props = filter.Props{ Delay: 1000, } @@ -68,7 +74,18 @@ func (f *ComponentFilter) Render(ctx context.Context, c *cptype.Component, scena Reload: true, }, } - f.State.Values.IterationIDs = []int64{defaultIterationRetriever(iterations)} + if f.FrontendUrlQuery != "" { + b, err := base64.StdEncoding.DecodeString(f.FrontendUrlQuery) + if err != nil { + return err + } + f.State.Values = FrontendConditions{} + if err := json.Unmarshal(b, &f.State.Values); err != nil { + return err + } + } else { + f.State.Values.IterationIDs = []int64{defaultIterationRetriever(iterations)} + } } f.State.Conditions = []filter.PropCondition{ @@ -100,9 +117,22 @@ func (f *ComponentFilter) Render(ctx context.Context, c *cptype.Component, scena HaveFilter: true, }, } + urlParam, err := f.generateUrlQueryParams() + if err != nil { + return err + } + f.State.Base64UrlQueryParams = urlParam return nil } +func (f *ComponentFilter) generateUrlQueryParams() (string, error) { + fb, err := json.Marshal(f.State.Values) + if err != nil { + return "", err + } + return base64.StdEncoding.EncodeToString(fb), nil +} + func (f *ComponentFilter) getPropIterationsOptions() (map[int64]apistructs.Iteration, []filter.PropConditionOption, error) { iterations, err := f.bdl.ListProjectIterations(apistructs.IterationPagingRequest{ PageNo: 1, PageSize: 1000, diff --git a/modules/dop/services/issue/issue.go b/modules/dop/services/issue/issue.go index 0d64bbb23e0..56f706e4f3d 100644 --- a/modules/dop/services/issue/issue.go +++ b/modules/dop/services/issue/issue.go @@ -502,15 +502,19 @@ func (svc *Issue) UpdateIssue(req apistructs.IssueUpdateRequest) error { return apierrors.ErrGetIssue.InternalError(err) } - if req.PlanFinishedAt != nil && req.PlanStartedAt != nil && req.PlanStartedAt.After(*req.PlanFinishedAt) { - return fmt.Errorf("plan started is after plan finished time") - } - if req.PlanFinishedAt != nil && issueModel.PlanStartedAt != nil && issueModel.PlanStartedAt.After(*req.PlanFinishedAt) { - return apierrors.ErrUpdateIssue.InvalidParameter("plan finished at") - } - if req.PlanStartedAt != nil && issueModel.PlanFinishedAt != nil && req.PlanStartedAt.After(*issueModel.PlanFinishedAt) { - return apierrors.ErrUpdateIssue.InvalidParameter("plan started at") + if req.PlanFinishedAt != nil && req.PlanStartedAt != nil { + if req.PlanStartedAt.After(*req.PlanFinishedAt) { + return fmt.Errorf("plan started is after plan finished time") + } + } else { + if req.PlanFinishedAt != nil && issueModel.PlanStartedAt != nil && issueModel.PlanStartedAt.After(*req.PlanFinishedAt) { + return apierrors.ErrUpdateIssue.InvalidParameter("plan finished at") + } + if req.PlanStartedAt != nil && issueModel.PlanFinishedAt != nil && req.PlanStartedAt.After(*issueModel.PlanFinishedAt) { + return apierrors.ErrUpdateIssue.InvalidParameter("plan started at") + } } + //如果是BUG从打开或者重新打开切换状态为已解决,修改责任人为当前用户 if issueModel.Type == apistructs.IssueTypeBug { currentState, err := svc.db.GetIssueStateByID(issueModel.State)