BrightSide Workbench Full Report + Source Code
IssueInfoVM.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.model;
20 
21 import java.util.Map;
22 import org.turro.attach.zul.control.AttachmentControl;
23 import org.turro.dossier.entity.Issue;
24 import org.turro.dossier.task.Tasks;
25 import org.turro.dossier.zul.menu.DossierMenu;
26 import org.turro.i18n.I_;
27 import org.turro.zkoss.dialog.Windows;
28 import org.zkoss.bind.annotation.Command;
29 import org.zkoss.bind.annotation.ExecutionArgParam;
30 import org.zkoss.bind.annotation.Init;
31 
36 public class IssueInfoVM {
37 
38  private Issue issue;
39 
40  @Init
41  public void init(@ExecutionArgParam("issue") Issue issue) {
42  this.issue = issue;
43  }
44 
45  @Command
46  public void showDossier() {
48  }
49 
50  @Command
51  public void showIssue() {
52  DossierMenu.showIssue(issue.getId());
53  }
54 
55  @Command
56  public void showSubtasks() {
57  Windows.title(I_.get("Subtasks"))
58  .addComponent("/issue/subtaskView.zul", Map.of("issue", issue))
59  .width("70%").height("50%").closeable().show();
60  }
61 
62  @Command
63  public void newSubtask() {
64  DossierMenu.addSubtask(issue, null);
65  }
66 
67  @Command
68  public void newRelation() {
69  DossierMenu.addRelation(issue, null);
70  }
71 
72  @Command
73  public void addInformation() {
74  DossierMenu.addInformation(issue, null);
75  }
76 
77  @Command
78  public void showAttachments() {
79  AttachmentControl.showFor(issue, null);
80  }
81 
82  public Issue getIssue() {
83  return issue;
84  }
85 
86  private double pcdone = - 1;
87 
88  public double percentDone() {
89  if(pcdone == -1) {
90  pcdone = Tasks.from(issue, false, false).getPercentTasksDone();
91  }
92  return pcdone;
93  }
94 
95  public boolean hasPercent() {
96  return percentDone() > 0;
97  }
98 
99 }
static void showFor(Object entity, Consumer< Windows > onClose)
void init(@ExecutionArgParam("issue") Issue issue)
static Tasks from(Dossier dossier, boolean onlyOpen, boolean sameDossier)
static void addSubtask(Issue issue, final Command command)
static void addRelation(Issue issue, final Command command)
static void addInformation(Issue issue, final Command command)
static void showDossier(Dossier dossier)
static String get(String msg)
Definition: I_.java:41
static Windows title(String title)
Definition: Windows.java:138
Windows addComponent(HtmlBasedComponent component)
Definition: Windows.java:97
Windows width(String width)
Definition: Windows.java:61
Windows height(String height)
Definition: Windows.java:66