Browse Source

nicer bigtext editor

Ondřej Hruška 3 months ago
parent
commit
ad6683adec
Signed by: Ondřej Hruška <ondra@ondrovo.com> GPG key ID: 2C5FD5035250423D

+ 3 - 2
yopa-web/resources/src/components/EditPropertyField.vue View File

@@ -54,11 +54,12 @@ export default {
54 54
       <label class="form-label" :for="widget_id" v-if="vi===0">{{ model.name }}</label>
55 55
     </div>
56 56
     <div class="col-9 pr-2">
57
-      <string-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String'"></string-value>
57
+      <string-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String' && !model.options.multiline"></string-value>
58
+      <text-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String' && model.options.multiline"></text-value>
58 59
       <integer-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Integer'"></integer-value>
59 60
       <decimal-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Decimal'"></decimal-value>
60 61
       <boolean-value :ref="setFieldRef" :value="instance.value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Boolean'"></boolean-value>
61
-      <button type="button" class="btn btn-delete ml-1" @click="removeValue(vi)" v-if="values.length > 1 || model.optional">
62
+      <button type="button" :class="['btn','btn-delete', (model.data_type==='String' && model.options.multiline)?'mt-1': 'ml-1']" @click="removeValue(vi)" v-if="values.length > 1 || model.optional">
62 63
         <i class="icon icon-cross"></i>Remove
63 64
       </button>
64 65
     </div>

+ 3 - 2
yopa-web/resources/src/components/PropertyField.vue View File

@@ -51,11 +51,12 @@ export default {
51 51
       <label class="form-label" :for="widget_id" v-if="vi===0">{{ model.name }}</label>
52 52
     </div>
53 53
     <div class="col-9 pr-2">
54
-      <string-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String'"></string-value>
54
+      <string-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String' && !model.options.multiline"></string-value>
55
+      <text-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='String' && model.options.multiline"></text-value>
55 56
       <integer-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Integer'"></integer-value>
56 57
       <decimal-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Decimal'"></decimal-value>
57 58
       <boolean-value :ref="setFieldRef" :value="value" :id="vi === 0 ? widget_id : null" v-if="model.data_type==='Boolean'"></boolean-value>
58
-      <button type="button" class="btn btn-delete ml-1" @click="removeValue(vi)" v-if="values.length > 1 || model.optional">
59
+      <button type="button" :class="['btn','btn-delete', (model.data_type==='String' && model.options.multiline)?'mt-1': 'ml-1']" @click="removeValue(vi)" v-if="values.length > 1 || model.optional">
59 60
         <i class="icon icon-cross"></i>Remove
60 61
       </button>
61 62
     </div>

+ 31 - 0
yopa-web/resources/src/components/value/TextValue.vue View File

@@ -0,0 +1,31 @@
1
+<script>
2
+export default {
3
+  name: "StringValue",
4
+  props: {
5
+    id: {
6
+      type: String,
7
+      default: '',
8
+    },
9
+    value: Object
10
+  },
11
+  methods: {
12
+    focus() {
13
+      this.$refs.input.focus();
14
+    }
15
+  },
16
+  computed: {
17
+    inputValue: {
18
+      set(value) {
19
+        this.value.String = value
20
+      },
21
+      get() {
22
+        return this.value.String;
23
+      }
24
+    }
25
+  }
26
+};
27
+</script>
28
+
29
+<template>
30
+  <textarea ref="input" class="form-input" style="resize: vertical" rows="6" :id="id" v-model="inputValue"></textarea>
31
+</template>

+ 1 - 1
yopa-web/resources/src/main.js View File

@@ -19,7 +19,7 @@ import {qs} from "./utils";
19 19
 
20 20
 function registerComponents(app) {
21 21
   app.component('string-value', StringValue);
22
-  app.component('text-value', StringValue);
22
+  app.component('text-value', TextValue);
23 23
   app.component('integer-value', IntegerValue);
24 24
   app.component('decimal-value', DecimalValue);
25 25
   app.component('boolean-value', BooleanValue);

+ 4 - 0
yopa-web/resources/src/style/app.scss View File

@@ -21,3 +21,7 @@ table.object-display {
21 21
 .hidden {
22 22
   display: none !important;
23 23
 }
24
+
25
+.text-pre {
26
+  white-space: pre-wrap;
27
+}

File diff suppressed because it is too large
+ 1 - 1
yopa-web/resources/static/bundle.js


File diff suppressed because it is too large
+ 1 - 1
yopa-web/resources/static/bundle.js.map


+ 3 - 0
yopa-web/resources/static/style.css View File

@@ -4132,3 +4132,6 @@ table.object-display {
4132 4132
 
4133 4133
 .hidden {
4134 4134
   display: none !important; }
4135
+
4136
+.text-pre {
4137
+  white-space: pre-wrap; }

+ 1 - 3
yopa-web/resources/templates/objects/object_detail.html.tera View File

@@ -30,9 +30,7 @@
30 30
 				{{ property.model.name }}
31 31
 			</th>
32 32
 			{% endif %}
33
-			<td title="{{value.id}}">
34
-				{{ value.value | print_typed_value }}
35
-			</td>
33
+			<td title="{{value.id}}" class="text-pre">{{ value.value | print_typed_value }}</td>
36 34
 		</tr>
37 35
 		{% endfor %}
38 36
 	{% endfor %}

+ 3 - 1
yopa-web/src/routes/models/object.rs View File

@@ -32,7 +32,9 @@ pub(crate) async fn create_form(session: Session) -> actix_web::Result<impl Resp
32 32
     if let Ok(Some(form)) = session.take::<ObjectModelForm>("old") {
33 33
         context.insert("old", &form);
34 34
     } else {
35
-        context.insert("old", &ObjectModelForm::default());
35
+        let mut f = ObjectModelForm::default();
36
+        f.sort_key = 1000;
37
+        context.insert("old", &f);
36 38
     }
37 39
 
38 40
     TERA.build_response("models/model_create", &context)