Skip to content

Commit 01b4cf2

Browse files
committed
Adds Raw props and datas
1 parent f7f6632 commit 01b4cf2

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
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.4</version>
9+
<version>1.0.5</version>
1010

1111
<name>springboot-vuejs</name>
1212
<url>https://github.com/jeeMv/SpringBoot-VueJS</url>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6+
import io.github.jeemv.springboot.vuejs.beans.RawObject;
67
import io.github.jeemv.springboot.vuejs.parts.VueComputeds;
78
import io.github.jeemv.springboot.vuejs.parts.VueData;
89
import io.github.jeemv.springboot.vuejs.parts.VueHook;
@@ -44,6 +45,15 @@ public void addData(String key,Object value) {
4445
data.put(key, value);
4546
}
4647

48+
/**
49+
* Adds a data and the exact value without transformation
50+
* @param key the name of the data
51+
* @param value the value
52+
*/
53+
public void addDataRaw(String key,String value) {
54+
data.put(key, new RawObject(value));
55+
}
56+
4757
/**
4858
* Declare a data
4959
* @param key the name of the data

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.fasterxml.jackson.core.JsonProcessingException;
1616
import io.github.jeemv.springboot.vuejs.AbstractVueJS;
1717
import io.github.jeemv.springboot.vuejs.VueConfig;
18+
import io.github.jeemv.springboot.vuejs.beans.RawObject;
1819
import io.github.jeemv.springboot.vuejs.console.CommandAction;
1920
import io.github.jeemv.springboot.vuejs.console.CommandPrompt;
2021
import io.github.jeemv.springboot.vuejs.parts.VueProps;
@@ -106,13 +107,38 @@ public void setProps(String...props) {
106107
}
107108
}
108109

110+
public VueProp addProp(String name,Object defaultValue) {
111+
VueProp prop=this.props.add(name);
112+
prop.setDefaultValue(defaultValue);
113+
return prop;
114+
}
115+
116+
public VueProp addPropRaw(String name,String defaultValue) {
117+
VueProp prop=this.props.add(name);
118+
prop.setDefaultValue(new RawObject(defaultValue));
119+
return prop;
120+
}
121+
109122
public VueProp addProp(String name,String type,boolean required) {
110123
VueProp prop=this.props.add(name);
111124
prop.setTypes(type);
112125
prop.setRequired(required);
113126
return prop;
114127
}
115128

129+
/**
130+
* Adds a mutable property (use mutProperty=value to assign a value)
131+
* @param name then name of the property
132+
* @param type the property type (Object,Array,Function,String,Number,Boolean)
133+
* @param required if true property is required
134+
* @param mutable if true property is mutable
135+
* @return the property added
136+
*/
137+
public VueProp addProp(String name,String type,boolean required,boolean mutable) {
138+
addComputed("mut"+name.substring(0, 1).toUpperCase() + name.substring(1), " return this."+name+";","this.$emit('update:"+name+"', v);");
139+
return addProp(name, type, required);
140+
}
141+
116142
protected void loadTemplateFile(String filename) throws IOException {
117143
Resource resource = new ClassPathResource(filename);
118144
InputStream resourceInputStream = resource.getInputStream();

src/main/java/io/github/jeemv/springboot/vuejs/utilities/Http.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public class Http {
1111

1212
private static boolean useAxios=false;
1313

14+
/**
15+
* Sets axios as library to use
16+
* do not forget to include the corresponding js file
17+
*/
1418
public static void useAxios() {
1519
useAxios=true;
1620
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.github.jeemv.springboot.vuejs.utilities;
2+
3+
public class Javascript {
4+
public static String copy(String from,String to) {
5+
return "for(var k in "+to+") {"+to+"[k]="+from+"[k];}";
6+
}
7+
8+
public static String clone(String from,String to,String initialize) {
9+
return to+"=Object.assign("+initialize+","+from+");";
10+
}
11+
12+
public static String clone(String from,String to) {
13+
return clone(from,to,"{}");
14+
}
15+
}

src/main/java/io/github/jeemv/springboot/vuejs/utilities/JsUtils.java

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

77
import com.fasterxml.jackson.core.JsonParseException;
88
import com.fasterxml.jackson.core.JsonProcessingException;
9+
import com.fasterxml.jackson.databind.DeserializationFeature;
910
import com.fasterxml.jackson.databind.JsonMappingException;
1011
import com.fasterxml.jackson.databind.ObjectMapper;
1112
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -60,6 +61,7 @@ public static String objectToJSON(Object o) throws JsonProcessingException {
6061

6162
public static <T> T jsonStringToObject(String jsonString,Class<T> clazz) throws JsonParseException, JsonMappingException, IOException {
6263
ObjectMapper mapper = new ObjectMapper();
64+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
6365
T o = mapper.readValue(jsonString,clazz);
6466
return o;
6567
}

0 commit comments

Comments
 (0)