Skip to content

Commit 4514f7d

Browse files
committed
Add shortHand directive + javadoc
1 parent 3ba0843 commit 4514f7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+331
-19
lines changed

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.jeemv.springboot.vuejs</groupId>
88
<artifactId>springboot-vuejs</artifactId>
9-
<version>1.0.11</version>
9+
<version>1.0.12</version>
1010

1111
<name>springboot-vuejs</name>
1212
<url>https://github.com/jeeMv/SpringBoot-VueJS</url>
@@ -48,39 +48,39 @@
4848
<dependency>
4949
<groupId>com.fasterxml.jackson.core</groupId>
5050
<artifactId>jackson-core</artifactId>
51-
<version>[2.9.8,)</version>
51+
<version>[2.10.0,)</version>
5252
</dependency>
5353
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
5454
<dependency>
5555
<groupId>com.fasterxml.jackson.core</groupId>
5656
<artifactId>jackson-databind</artifactId>
57-
<version>[2.9.8,)</version>
57+
<version>[2.10.0,)</version>
5858
</dependency>
5959
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
6060
<dependency>
6161
<groupId>org.aspectj</groupId>
6262
<artifactId>aspectjweaver</artifactId>
63-
<version>1.9.1</version>
63+
<version>1.9.4</version>
6464
</dependency>
6565
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
6666
<dependency>
6767
<groupId>org.springframework</groupId>
6868
<artifactId>spring-context</artifactId>
69-
<version>5.1.0.RELEASE</version>
69+
<version>5.2.0.RELEASE</version>
7070
</dependency>
7171

7272
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
7373
<dependency>
7474
<groupId>org.springframework.boot</groupId>
7575
<artifactId>spring-boot-starter-web</artifactId>
76-
<version>2.1.3.RELEASE</version>
76+
<version>2.1.9.RELEASE</version>
7777
</dependency>
7878

7979
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor -->
8080
<dependency>
8181
<groupId>org.springframework.boot</groupId>
8282
<artifactId>spring-boot-configuration-processor</artifactId>
83-
<version>2.1.3.RELEASE</version>
83+
<version>2.1.9.RELEASE</version>
8484
</dependency>
8585

8686
</dependencies>

src/main/java/io/github/jeemv/springboot/vuejs/AbstractVueJS.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
import io.github.jeemv.springboot.vuejs.parts.VueWatcher;
1616
import io.github.jeemv.springboot.vuejs.parts.VueWatchers;
1717

18+
/**
19+
* AbstractVueJS
20+
* This class is part of springBoot-VueJS
21+
* @author jcheron myaddressmail@gmail.com
22+
* @version 1.0.0
23+
*
24+
*/
1825
public abstract class AbstractVueJS {
1926
protected VueData data;
2027
protected VueMethods methods;
@@ -219,6 +226,16 @@ public VueDirective addDirective(String name) {
219226
return directives.add(name);
220227
}
221228

229+
/**
230+
* Adds a new directive in the vue instance
231+
* @param name The directive name
232+
* @param shortHand Shorthand function for bind and update
233+
* @return The created directive
234+
*/
235+
public VueDirective addDirective(String name,String shortHand) {
236+
return directives.add(name,shortHand);
237+
}
238+
222239
/**
223240
* Adds a new filter in the vue instance
224241
* @param name The filter name

src/main/java/io/github/jeemv/springboot/vuejs/VueJS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* VueJS instance
2727
* This class is part of springBoot-VueJS
28-
* @author jc
28+
* @author jcheron myaddressmail@gmail.com
2929
* @version 1.0.3
3030
*
3131
*/

src/main/java/io/github/jeemv/springboot/vuejs/annotations/VueJSInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* This class is part of spring-boot-vuejs
1212
* inject an instance of VueJS initialized from the parameters selector and modelName.
1313
* The annotated method must take the ModelMap and VueJS type parameters at the last position.
14-
* @author jc
14+
* @author jcheron myaddressmail@gmail.com
1515
* @since 1.0.2
1616
*
1717
*/

src/main/java/io/github/jeemv/springboot/vuejs/beans/RawObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* RawObject
66
* This class is part of spring-boot-vuejs
7-
* @author jc
7+
* @author jcheron myaddressmail@gmail.com
88
* @version 1.0.0
99
*
1010
*/

src/main/java/io/github/jeemv/springboot/vuejs/components/VueComponent.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/**
3434
* VueJS component class
3535
* This class is part of springBoot-VueJS
36+
* Components are create in src/main/resources/static/
3637
* @author jc
3738
* @version 1.0.1
3839
*
@@ -84,10 +85,18 @@ public String getTemplate() {
8485
return template;
8586
}
8687

88+
/**
89+
* Defines the template string
90+
* @param template
91+
*/
8792
public void setTemplate(String template) {
8893
this.template = template;
8994
}
9095

96+
/**
97+
* Sets a template file
98+
* @param pathFilename
99+
*/
91100
public void setTemplateFile(String pathFilename) {
92101
try {
93102
loadTemplateFile("templates/"+pathFilename);
@@ -97,6 +106,9 @@ public void setTemplateFile(String pathFilename) {
97106
}
98107
}
99108

109+
/**
110+
* Sets the default template file (componentName+".html")
111+
*/
100112
public void setDefaultTemplateFile() {
101113
setTemplateFile(VueConfig.getTemplateComponentFolder()+"/"+name+".html");
102114
}
@@ -105,6 +117,10 @@ public boolean isInternal() {
105117
return internal;
106118
}
107119

120+
/**
121+
* Defines if the component is created in the vue instance or not
122+
* @param internal
123+
*/
108124
public void setInternal(boolean internal) {
109125
this.internal = internal;
110126
}
@@ -113,24 +129,48 @@ public VueProps getProps() {
113129
return props;
114130
}
115131

132+
/**
133+
* Sets the component properties
134+
* @param props
135+
*/
116136
public void setProps(String...props) {
117137
for(String prop:props) {
118138
this.props.add(prop);
119139
}
120140
}
121141

142+
/**
143+
* Adds a new property to the component
144+
* @param name The property name
145+
* @param defaultValue The property default value
146+
* @return
147+
*/
122148
public VueProp addProp(String name,Object defaultValue) {
123149
VueProp prop=this.props.add(name);
124150
prop.setDefaultValue(defaultValue);
125151
return prop;
126152
}
127153

154+
/**
155+
* Adds a new property to the component
156+
* defaultValue is not quoted (because it's a raw property)
157+
* @param name The property name
158+
* @param defaultValue non quoted value
159+
* @return
160+
*/
128161
public VueProp addPropRaw(String name,String defaultValue) {
129162
VueProp prop=this.props.add(name);
130163
prop.setDefaultValue(new RawObject(defaultValue));
131164
return prop;
132165
}
133166

167+
/**
168+
* Adds a required property to the component
169+
* @param name The property name
170+
* @param type The property type
171+
* @param required true if the property is required
172+
* @return
173+
*/
134174
public VueProp addProp(String name,String type,boolean required) {
135175
VueProp prop=this.props.add(name);
136176
prop.setTypes(type);

src/main/java/io/github/jeemv/springboot/vuejs/components/VueProp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Represents a VueJS property for Components
1414
* This class is part of springBoot-VueJS
15-
* @author jc
15+
* @author jcheron myaddressmail@gmail.com
1616
* @version 1.0.0
1717
*
1818
*/

src/main/java/io/github/jeemv/springboot/vuejs/configuration/VueConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* VueConfig (Used for components creation)
77
* This class is part of springBoot-VueJS
8-
* @author jc
8+
* @author jcheron myaddressmail@gmail.com
99
* @version 1.0.0
1010
*
1111
*/

src/main/java/io/github/jeemv/springboot/vuejs/console/CommandAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package io.github.jeemv.springboot.vuejs.console;
22

33

4+
/**
5+
* CommandAction
6+
* This class is part of springBoot-VueJS
7+
* @author jcheron myaddressmail@gmail.com
8+
* @version 1.0.0
9+
*
10+
*/
411
public class CommandAction {
512
private Runnable action;
613
private String option;

src/main/java/io/github/jeemv/springboot/vuejs/console/CommandPrompt.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
import java.util.List;
55
import java.util.Scanner;
66

7+
/**
8+
* CommandPrompt
9+
* This class is part of springBoot-VueJS
10+
* @author jcheron myaddressmail@gmail.com
11+
* @version 1.0.0
12+
*
13+
*/
714
public class CommandPrompt {
815
private String prompt;
916
private List<CommandAction> actions;

src/main/java/io/github/jeemv/springboot/vuejs/parts/AbstractVueComposition.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
import io.github.jeemv.springboot.vuejs.utilities.JsUtils;
44

5+
/**
6+
* AbstractVueComposition
7+
* This class is part of springBoot-VueJS
8+
* @author jcheron myaddressmail@gmail.com
9+
* @version 1.0.0
10+
*
11+
*/
512
public abstract class AbstractVueComposition {
613
protected String name;
714
protected boolean internal;

src/main/java/io/github/jeemv/springboot/vuejs/parts/VueComputed.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* VueComputed
55
* represents a computed property
66
* This class is part of springBoot-VueJS
7-
* @author jc
7+
* @author jcheron myaddressmail@gmail.com
88
* @version 1.0.0
99
*
1010
*/

src/main/java/io/github/jeemv/springboot/vuejs/parts/VueComputeds.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import io.github.jeemv.springboot.vuejs.configuration.VueConfig;
44
import io.github.jeemv.springboot.vuejs.utilities.JsUtils;
55

6+
/**
7+
* VueComputeds
8+
* This class is part of springBoot-VueJS
9+
* @author jcheron myaddressmail@gmail.com
10+
* @version 1.0.0
11+
*
12+
*/
613
public class VueComputeds extends VuePart {
714

815
public void add(String name,String get,String set) {

src/main/java/io/github/jeemv/springboot/vuejs/parts/VueData.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package io.github.jeemv.springboot.vuejs.parts;
22

33

4+
/**
5+
* VueData
6+
* This class is part of springBoot-VueJS
7+
* @author jcheron myaddressmail@gmail.com
8+
* @version 1.0.0
9+
*
10+
*/
411
public class VueData extends VuePart {
512

613
@Override

src/main/java/io/github/jeemv/springboot/vuejs/parts/VueDirective.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
package io.github.jeemv.springboot.vuejs.parts;
22

3+
/**
4+
* VueDirective
5+
* This class is part of springBoot-VueJS
6+
* @author jcheron myaddressmail@gmail.com
7+
* @version 1.0.0
8+
*
9+
*/
310
public class VueDirective extends AbstractVueComposition{
411
protected VueMethods methods;
12+
protected VueMethod shortHand;
513

614
public VueDirective() {
715
super();
816
methods=new VueMethods();
917
}
1018

19+
/**
20+
* @param name The directive name (ex: demo for v-demo directive)
21+
*/
1122
public VueDirective(String name) {
1223
super(name);
1324
methods=new VueMethods();
1425
}
26+
27+
/**
28+
* @param name The directive name
29+
* @param shortHand Same behavior on bind and update, but don’t care about the other hooks
30+
*/
31+
public VueDirective(String name,String shortHand) {
32+
super(name);
33+
setShortHand(shortHand);
34+
}
35+
36+
public void setShortHand(String shortHand) {
37+
this.shortHand=new VueMethod(shortHand,"el","binding","vnode");
38+
}
1539

1640
/**
1741
* called only once, when the directive is first bound to the element. This is where you can do one-time setup work.
@@ -66,18 +90,35 @@ public VueDirective onUnbind(String body) {
6690
return on("unbind", body);
6791
}
6892

93+
/**
94+
* Adds an event in the directive
95+
*
96+
* @param event The associated event
97+
* @param body The javascript code associated
98+
* @return
99+
*/
69100
protected VueDirective on(String event,String body) {
70101
methods.add(event, body, "el", "binding", "vnode");
71102
return this;
72103
}
73104

74105
@Override
75106
public String toString() {
107+
if(shortHand instanceof VueMethod) {
108+
return shortHand.toString();
109+
}
76110
return methods.toString();
77111
}
78112

79113
@Override
80114
public String getType() {
81115
return "directive";
82116
}
117+
118+
/**
119+
* To also detect nested value changes inside Objects
120+
*/
121+
public void setDeep() {
122+
methods.addProperty("deep", true);
123+
}
83124
}

0 commit comments

Comments
 (0)