BrightSide Workbench Full Report + Source Code
org.turro.web.funnel.model.FunnelItemsVM Class Reference

Public Member Functions

WebItem getSelected ()
 
void setSelected (WebItem selected)
 
String getBehaveString ()
 
String getGraphDOT ()
 
boolean isShowForm ()
 
void addItem ()
 
void save ()
 
void addNext (@BindingParam("next") WebItem item)
 
void addGoal (@BindingParam("goal") WebGoal goal)
 
void addExt ()
 
void delete ()
 
void deleteNext (@BindingParam("next") WebItem item)
 
void deleteGoal (@BindingParam("goal") WebGoal goal)
 
void deleteExt (@BindingParam("ext") String item)
 
List< WebItemgetModel ()
 
List< WebItemgetNextsModel ()
 
List< WebGoalgetGoalsModel ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 51 of file FunnelItemsVM.java.

Member Function Documentation

◆ addExt()

void org.turro.web.funnel.model.FunnelItemsVM.addExt ( )

Definition at line 134 of file FunnelItemsVM.java.

134  {
135  Dialogs.title(I_.get("Add external"))
136  .width("400px")
137  .height("300px")
138  .addField(DialogField.field("Type")
139  .help("https://www.turro.org/docs/elephant/components/webactions")
140  .onEditor(() -> {
141  WebActionTypeListbox wat = new WebActionTypeListbox();
142  wat.setMold("select");
143  wat.setObjectValue(WebActionType.NAVIGATE);
144  return wat;
145  }))
146  .addField(DialogField.field("Value"))
147  .addField(DialogField.field("Icon"))
148  .onOk((dialogs) -> {
149  WebActionType type = dialogs.<WebActionTypeListbox>getEditor("Type").getObjectValue();
150  String value = dialogs.<Textbox>getEditor("Value").getValue();
151  String image = dialogs.<Textbox>getEditor("Icon").getValue();
152  if(type != null && !Strings.isBlank(value)) {
153  selected.getExternals().add(type.getProtocol() + ":" + value +
154  (Strings.isBlank(image) ? "" : "{" + image + "}"));
155  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
156  "selected");
157  }
158  })
159  .emptyCancel()
160  .show();
161  }
Here is the call graph for this function:

◆ addGoal()

void org.turro.web.funnel.model.FunnelItemsVM.addGoal ( @BindingParam("goal") WebGoal  goal)

Definition at line 130 of file FunnelItemsVM.java.

130  {
131  selected.getGoals().add(goal);
132  }
Here is the call graph for this function:

◆ addItem()

void org.turro.web.funnel.model.FunnelItemsVM.addItem ( )

Definition at line 81 of file FunnelItemsVM.java.

81  {
82  Dialogs.title(I_.get("Add"))
83  .width("400px")
84  .height("250px")
85  .addField(DialogField.field("WebTag"))
86  .addField(DialogField.field("Type").onEditor(() -> {
87  WebItemTypeListbox wit = new WebItemTypeListbox();
88  wit.setMold("select");
89  wit.setObjectValue(WebItemType.TARGET);
90  return wit;
91  }))
92  .onOk((dialogs) -> {
93  String webTag = dialogs.<Textbox>getEditor("WebTag").getValue();
94  if(notInModel(webTag)) {
95  WebItem wi = new WebItem();
96  wi.setWebTag(webTag);
97  wi.setType(dialogs.<WebItemTypeListbox>getEditor("Type").getObjectValue());
98  if(wi.isValid()) {
99  model.add(wi);
100  selected = wi;
101  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
102  "model", "selected", "showForm");
103  } else {
104  Toasts.message("WebTags should not include spaces or punctuation characters.").show();
105  }
106  } else {
107  Toasts.message("WebTag already in the model.").show();
108  }
109  })
110  .emptyCancel()
111  .show();
112  }
Here is the call graph for this function:

◆ addNext()

void org.turro.web.funnel.model.FunnelItemsVM.addNext ( @BindingParam("next") WebItem  item)

Definition at line 125 of file FunnelItemsVM.java.

125  {
126  selected.getNexts().add(item);
127  }
Here is the call graph for this function:

◆ delete()

void org.turro.web.funnel.model.FunnelItemsVM.delete ( )

Definition at line 163 of file FunnelItemsVM.java.

163  {
164  Messages.confirmDeletion().add(selected.getItemLabel()).show(() -> {
165  dao.get().deleteObject(selected);
166  Executions.getCurrent().sendRedirect(null);
167  });
168  }
Here is the call graph for this function:

◆ deleteExt()

void org.turro.web.funnel.model.FunnelItemsVM.deleteExt ( @BindingParam("ext") String  item)

Definition at line 186 of file FunnelItemsVM.java.

186  {
187  Messages.confirmDeletion().add(item).show(() -> {
188  selected.getExternals().remove(item);
189  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
190  "selected");
191  });
192  }
Here is the call graph for this function:

◆ deleteGoal()

void org.turro.web.funnel.model.FunnelItemsVM.deleteGoal ( @BindingParam("goal") WebGoal  goal)

Definition at line 178 of file FunnelItemsVM.java.

178  {
179  Messages.confirmDeletion().add(goal.getItemLabel()).show(() -> {
180  selected.getGoals().remove(goal);
181  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
182  "model", "selected");
183  });
184  }
Here is the call graph for this function:

◆ deleteNext()

void org.turro.web.funnel.model.FunnelItemsVM.deleteNext ( @BindingParam("next") WebItem  item)

Definition at line 170 of file FunnelItemsVM.java.

170  {
171  Messages.confirmDeletion().add(item.getItemLabel()).show(() -> {
172  selected.getNexts().remove(item);
173  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
174  "model", "selected");
175  });
176  }
Here is the call graph for this function:

◆ getBehaveString()

String org.turro.web.funnel.model.FunnelItemsVM.getBehaveString ( )

Definition at line 64 of file FunnelItemsVM.java.

64  {
65  if(selected == null || behaveAs == null) return "wrong";
66  if(selected.getType().equals(behaveAs)) return "equal";
67  if(WebItemType.CHAIN.equals(behaveAs)) return "wrong";
68  return behaveAs.toString();
69  }
Here is the call graph for this function:

◆ getGoalsModel()

List<WebGoal> org.turro.web.funnel.model.FunnelItemsVM.getGoalsModel ( )

Definition at line 237 of file FunnelItemsVM.java.

237  {
238  if(selected == null) return Collections.EMPTY_LIST;
239  return SqlClause.select("wg").from("WebGoal wg")
240  .where().notIn("goalAction", selected.getGoals().stream().map(wi -> wi.getGoalAction()).toList())
241  .dao(dao.get())
242  .resultList(WebGoal.class);
243  }

◆ getGraphDOT()

String org.turro.web.funnel.model.FunnelItemsVM.getGraphDOT ( )

Definition at line 71 of file FunnelItemsVM.java.

71  {
72  Writer writer = new StringWriter();
73  FunnelGraphDOT.DOT(writer);
74  return writer.toString();
75  }
Here is the call graph for this function:

◆ getModel()

List<WebItem> org.turro.web.funnel.model.FunnelItemsVM.getModel ( )

Definition at line 217 of file FunnelItemsVM.java.

217  {
218  if(model == null) {
219  model = SqlClause.select("wi").from("WebItem wi")
220  .orderBy("type, ordering, webTag")
221  .dao(dao.get())
222  .resultList(WebItem.class);
223  }
224  return model;
225  }

◆ getNextsModel()

List<WebItem> org.turro.web.funnel.model.FunnelItemsVM.getNextsModel ( )

Definition at line 227 of file FunnelItemsVM.java.

227  {
228  if(selected == null) return Collections.EMPTY_LIST;
229  return SqlClause.select("wi").from("WebItem wi")
230  .where().in("type", getPossibleNextTypes())
231  .and().notEqual("webTag", selected.getWebTag())
232  .and().notIn("webTag", selected.getNexts().stream().map(wi -> wi.getWebTag()).toList())
233  .dao(dao.get())
234  .resultList(WebItem.class);
235  }

◆ getSelected()

WebItem org.turro.web.funnel.model.FunnelItemsVM.getSelected ( )

Definition at line 53 of file FunnelItemsVM.java.

53  {
54  return selected;
55  }

◆ isShowForm()

boolean org.turro.web.funnel.model.FunnelItemsVM.isShowForm ( )

Definition at line 77 of file FunnelItemsVM.java.

77  {
78  return selected != null;
79  }

◆ save()

void org.turro.web.funnel.model.FunnelItemsVM.save ( )

Definition at line 115 of file FunnelItemsVM.java.

115  {
116  model.stream().filter(wi -> wi.isEmpty() && !wi.isNew())
117  .forEach(wi -> dao.get().deleteEntity(wi));
118  model.removeIf(wi -> wi.isEmpty());
119  model.forEach(wi -> wi.compose());
120  dao.get().saveEntities(model);
121  Executions.getCurrent().sendRedirect(null);
122  }

◆ setSelected()

void org.turro.web.funnel.model.FunnelItemsVM.setSelected ( WebItem  selected)

Definition at line 57 of file FunnelItemsVM.java.

57  {
58  this.selected = selected;
59  this.behaveAs = FunnelGraph.behaveAs(selected);
60  BindUtils.postNotifyChange(null, null, FunnelItemsVM.this,
61  "selected", "behaveString", "showForm", "nextsModel");
62  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: