16
16
*/
17
17
package com .mycollab .module .project .view .settings ;
18
18
19
- import com .mycollab .db .arguments .NumberSearchField ;
19
+ import com .mycollab .core .utils .DateTimeUtils ;
20
+ import com .mycollab .db .arguments .DateSearchField ;
21
+ import com .mycollab .db .arguments .SearchField ;
20
22
import com .mycollab .db .arguments .SetSearchField ;
21
23
import com .mycollab .module .project .CurrentProjectVariables ;
22
24
import com .mycollab .module .project .ProjectTypeConstants ;
23
- import com .mycollab .module .project .view .bug .BugRowRenderer ;
24
- import com .mycollab .module .project .view .settings .component .ProjectUserFormLinkField ;
25
25
import com .mycollab .module .project .domain .Component ;
26
- import com .mycollab .module .project .domain .SimpleBug ;
26
+ import com .mycollab .module .project .domain .ProjectTicket ;
27
27
import com .mycollab .module .project .domain .SimpleComponent ;
28
- import com .mycollab .module .project .domain .criteria .BugSearchCriteria ;
29
- import com .mycollab .module .project .service .BugService ;
28
+ import com .mycollab .module .project .domain .criteria .ProjectTicketSearchCriteria ;
29
+ import com .mycollab .module .project .service .ProjectTicketService ;
30
+ import com .mycollab .module .project .view .settings .component .ProjectUserFormLinkField ;
31
+ import com .mycollab .module .project .view .ticket .TicketRowRenderer ;
30
32
import com .mycollab .spring .AppContextUtil ;
31
33
import com .mycollab .vaadin .UserUIContext ;
32
34
import com .mycollab .vaadin .ui .AbstractBeanFieldGroupViewFieldFactory ;
36
38
import com .mycollab .vaadin .web .ui .DefaultBeanPagedList ;
37
39
import com .mycollab .vaadin .web .ui .DefaultDynaFormLayout ;
38
40
import com .mycollab .vaadin .web .ui .field .ContainerViewField ;
41
+ import com .vaadin .data .HasValue ;
39
42
import com .vaadin .ui .Alignment ;
40
43
import com .vaadin .ui .CheckBox ;
41
- import com .vaadin .data .HasValue ;
42
44
import com .vaadin .ui .Label ;
43
45
import org .vaadin .viritin .layouts .MHorizontalLayout ;
44
46
import org .vaadin .viritin .layouts .MVerticalLayout ;
52
54
public class ComponentPreviewForm extends AdvancedPreviewBeanForm <SimpleComponent > {
53
55
@ Override
54
56
public void setBean (SimpleComponent bean ) {
55
- setFormLayoutFactory (new DefaultDynaFormLayout (ProjectTypeConstants .COMPONENT , ComponentDefaultFormLayoutFactory .getForm (),
57
+ setFormLayoutFactory (new DefaultDynaFormLayout (ProjectTypeConstants .COMPONENT , ComponentDefaultFormLayoutFactory .getReadForm (),
56
58
Component .Field .name .name ()));
57
59
setBeanFormFieldFactory (new ReadFormFieldFactory (this ));
58
60
super .setBean (bean );
@@ -71,9 +73,9 @@ protected HasValue<?> onCreateField(Object propertyId) {
71
73
if (Component .Field .userlead .equalTo (propertyId )) {
72
74
return new ProjectUserFormLinkField (beanItem .getProjectid (), beanItem .getUserlead (),
73
75
beanItem .getUserLeadAvatarId (), beanItem .getUserLeadFullName ());
74
- } else if (Component . Field . id . equalTo (propertyId )) {
76
+ } else if ("section-assignments" . equals (propertyId )) {
75
77
ContainerViewField containerField = new ContainerViewField ();
76
- containerField .addComponentField (new BugsComp (beanItem ));
78
+ containerField .addComponentField (new TicketsComp (beanItem ));
77
79
return containerField ;
78
80
} else if (Component .Field .description .equalTo (propertyId )) {
79
81
return new RichTextViewField ();
@@ -82,60 +84,53 @@ protected HasValue<?> onCreateField(Object propertyId) {
82
84
}
83
85
}
84
86
85
- private static class BugsComp extends MVerticalLayout {
86
- private BugSearchCriteria searchCriteria ;
87
- private DefaultBeanPagedList <BugService , BugSearchCriteria , SimpleBug > bugList ;
87
+ private static class TicketsComp extends MVerticalLayout {
88
+ private ProjectTicketSearchCriteria searchCriteria ;
89
+ private DefaultBeanPagedList <ProjectTicketService , ProjectTicketSearchCriteria , ProjectTicket > ticketList ;
88
90
89
- BugsComp (SimpleComponent beanItem ) {
91
+ TicketsComp (SimpleComponent beanItem ) {
90
92
withMargin (false ).withFullWidth ();
91
93
MHorizontalLayout header = new MHorizontalLayout ().withFullWidth ();
92
94
93
- final CheckBox openSelection = new BugStatusCheckbox (StatusI18nEnum .Open , true );
94
- CheckBox reOpenSelection = new BugStatusCheckbox (StatusI18nEnum .ReOpen , true );
95
- CheckBox verifiedSelection = new BugStatusCheckbox (StatusI18nEnum .Verified , true );
96
- CheckBox resolvedSelection = new BugStatusCheckbox (StatusI18nEnum .Resolved , true );
95
+ CheckBox openSelection = new CheckBox (UserUIContext .getMessage (StatusI18nEnum .Open ), true );
96
+ openSelection .addValueChangeListener (valueChangeEvent -> {
97
+ if (openSelection .getValue ()) {
98
+ searchCriteria .setOpen (new SearchField ());
99
+ } else {
100
+ searchCriteria .setOpen (null );
101
+ }
102
+ updateSearchStatus ();
103
+ });
104
+
105
+ CheckBox overdueSelection = new CheckBox (UserUIContext .getMessage (StatusI18nEnum .Overdue ), false );
106
+ overdueSelection .addValueChangeListener (valueChangeEvent -> {
107
+ if (overdueSelection .getValue ()) {
108
+ searchCriteria .setDueDate (new DateSearchField (DateTimeUtils .getCurrentDateWithoutMS ().toLocalDate (),
109
+ DateSearchField .LESS_THAN ));
110
+ } else {
111
+ searchCriteria .setDueDate (null );
112
+ }
113
+ updateSearchStatus ();
114
+ });
97
115
98
116
Label spacingLbl1 = new Label ("" );
99
117
100
- header .with (openSelection , reOpenSelection , verifiedSelection ,
101
- resolvedSelection , spacingLbl1 ).alignAll (Alignment .MIDDLE_LEFT ).expand (spacingLbl1 );
118
+ header .with (openSelection , overdueSelection , spacingLbl1 ).alignAll (Alignment .MIDDLE_LEFT ).expand (spacingLbl1 );
102
119
103
- bugList = new DefaultBeanPagedList (AppContextUtil .getSpringBean (BugService .class ), new BugRowRenderer ());
104
- bugList .setControlStyle ("" );
120
+ ticketList = new DefaultBeanPagedList (AppContextUtil .getSpringBean (ProjectTicketService .class ), new TicketRowRenderer ());
121
+ ticketList .setControlStyle ("" );
105
122
106
- searchCriteria = new BugSearchCriteria ();
107
- searchCriteria .setProjectId (new NumberSearchField (CurrentProjectVariables .getProjectId ()));
108
- searchCriteria .setComponentids (new SetSearchField <>(beanItem .getId ()));
109
- searchCriteria .setStatuses (new SetSearchField <>(StatusI18nEnum .Open .name (), StatusI18nEnum .ReOpen .name (),
110
- StatusI18nEnum .Verified .name (), StatusI18nEnum .Resolved .name ()));
123
+ searchCriteria = new ProjectTicketSearchCriteria ();
124
+ searchCriteria .setProjectIds (new SetSearchField <>(CurrentProjectVariables .getProjectId ()));
125
+ searchCriteria .setComponentIds (new SetSearchField <>(beanItem .getId ()));
126
+ searchCriteria .setTypes (new SetSearchField <>(ProjectTypeConstants .BUG , ProjectTypeConstants .TASK ));
111
127
updateSearchStatus ();
112
128
113
- this .with (header , bugList );
114
- }
115
-
116
- private void updateTypeSearchStatus (boolean selection , String type ) {
117
- SetSearchField <String > types = searchCriteria .getStatuses ();
118
- if (types == null ) {
119
- types = new SetSearchField <>();
120
- }
121
- if (selection ) {
122
- types .addValue (type );
123
- } else {
124
- types .removeValue (type );
125
- }
126
- searchCriteria .setStatuses (types );
127
- updateSearchStatus ();
129
+ this .with (header , ticketList );
128
130
}
129
131
130
132
private void updateSearchStatus () {
131
- bugList .setSearchCriteria (searchCriteria );
132
- }
133
-
134
- private class BugStatusCheckbox extends CheckBox {
135
- BugStatusCheckbox (final Enum name , boolean defaultValue ) {
136
- super (UserUIContext .getMessage (name ), defaultValue );
137
- this .addValueChangeListener (valueChangeEvent -> updateTypeSearchStatus (BugStatusCheckbox .this .getValue (), name .name ()));
138
- }
133
+ ticketList .setSearchCriteria (searchCriteria );
139
134
}
140
135
}
141
136
}
0 commit comments