g3w-admin-processing 1.2.1b1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- g3w_admin_processing-1.2.1b1.dev1.dist-info/METADATA +258 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/RECORD +80 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/WHEEL +5 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/licenses/LICENSE +373 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/top_level.txt +1 -0
- qprocessing/__init__.py +7 -0
- qprocessing/admin.py +21 -0
- qprocessing/api/__init__.py +0 -0
- qprocessing/api/permissions.py +41 -0
- qprocessing/api/views/__init__.py +4 -0
- qprocessing/api/views/actions.py +84 -0
- qprocessing/api/views/admin.py +76 -0
- qprocessing/api/views/models.py +219 -0
- qprocessing/api/views/upload.py +177 -0
- qprocessing/apiurls.py +64 -0
- qprocessing/apps.py +38 -0
- qprocessing/configs.py +131 -0
- qprocessing/forms.py +133 -0
- qprocessing/migrations/0001_initial.py +24 -0
- qprocessing/migrations/0002_auto_20230615_1609.py +23 -0
- qprocessing/migrations/0003_qprocessinginputupload.py +32 -0
- qprocessing/migrations/0004_auto_20230809_0920.py +26 -0
- qprocessing/migrations/0005_alter_qprocessinginputupload_user.py +21 -0
- qprocessing/migrations/__init__.py +0 -0
- qprocessing/models.py +143 -0
- qprocessing/receivers.py +100 -0
- qprocessing/sitetrees.py +31 -0
- qprocessing/static/qprocessing/js/components/DrawInputVectorFeatures.js +180 -0
- qprocessing/static/qprocessing/js/components/InputFieldChooser.js +226 -0
- qprocessing/static/qprocessing/js/components/InputPrjRasterLayer.js +135 -0
- qprocessing/static/qprocessing/js/components/InputPrjVectorLayer.js +415 -0
- qprocessing/static/qprocessing/js/components/ModelPanel.js +496 -0
- qprocessing/static/qprocessing/js/components/ModelResults.js +73 -0
- qprocessing/static/qprocessing/js/components/OutputFile.js +63 -0
- qprocessing/static/qprocessing/js/components/OutputRasterLayer.js +63 -0
- qprocessing/static/qprocessing/js/components/OutputVectorLayer.js +115 -0
- qprocessing/static/qprocessing/js/components/UploadVectorFile.js +53 -0
- qprocessing/static/qprocessing/js/i18n/en.js +33 -0
- qprocessing/static/qprocessing/js/i18n/index.js +7 -0
- qprocessing/static/qprocessing/js/i18n/it.js +33 -0
- qprocessing/static/qprocessing/js/plugin.js +122 -0
- qprocessing/tasks.py +136 -0
- qprocessing/templates/qprocessing/project_form.html +70 -0
- qprocessing/templates/qprocessing/projects_list.html +72 -0
- qprocessing/tests/__init__.py +0 -0
- qprocessing/tests/base.py +104 -0
- qprocessing/tests/data/models/qbuffer.model3 +233 -0
- qprocessing/tests/data/models/qintersection.model3 +288 -0
- qprocessing/tests/data/models/qpointspolygons.model3 +222 -0
- qprocessing/tests/data/models/test.model3 +321 -0
- qprocessing/tests/data/models/test_buffer_all_inputs.model3 +269 -0
- qprocessing/tests/data/models/test_buffer_layer1.model3 +201 -0
- qprocessing/tests/data/project_data/buildings.geojson +15 -0
- qprocessing/tests/data/project_data/qprocessing.gpkg +0 -0
- qprocessing/tests/data/qprocessing_qprocessing.qgs +2813 -0
- qprocessing/tests/data/qprocessing_qprocessing_attachments.zip +0 -0
- qprocessing/tests/data/test_qgis_328.qgs +954 -0
- qprocessing/tests/data/test_qgis_328_attachments.zip +0 -0
- qprocessing/tests/data/upload/fail_shp_to_upload.zip +0 -0
- qprocessing/tests/data/upload/linestring_to_upload.geojson +9 -0
- qprocessing/tests/data/upload/point_to_upload.geojson +10 -0
- qprocessing/tests/data/upload/point_to_upload_espg4326.geojson +10 -0
- qprocessing/tests/data/upload/point_to_upload_espg4326.qmd +26 -0
- qprocessing/tests/data/upload/polygon_to_upload.geojson +9 -0
- qprocessing/tests/data/upload/shp_to_upload.cpg +1 -0
- qprocessing/tests/data/upload/shp_to_upload.dbf +0 -0
- qprocessing/tests/data/upload/shp_to_upload.prj +1 -0
- qprocessing/tests/data/upload/shp_to_upload.qix +0 -0
- qprocessing/tests/data/upload/shp_to_upload.shp +0 -0
- qprocessing/tests/data/upload/shp_to_upload.shx +0 -0
- qprocessing/tests/data/upload/shp_to_upload.zip +0 -0
- qprocessing/tests/test_algorithm.py +52 -0
- qprocessing/tests/test_api.py +173 -0
- qprocessing/tests/test_api_models.py +459 -0
- qprocessing/urls.py +33 -0
- qprocessing/utils/__init__.py +0 -0
- qprocessing/utils/data.py +283 -0
- qprocessing/utils/exceptions.py +20 -0
- qprocessing/utils/formtypes.py +521 -0
- qprocessing/views.py +96 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
const { GUI } = g3wsdk.gui;
|
|
2
|
+
const { tPlugin } = g3wsdk.core.i18n;
|
|
3
|
+
|
|
4
|
+
export default ({
|
|
5
|
+
|
|
6
|
+
// language=html
|
|
7
|
+
template: /* html */ `
|
|
8
|
+
<div
|
|
9
|
+
class = "qprocessing-draw-vector-features"
|
|
10
|
+
style = "font-size: 1.3em;"
|
|
11
|
+
>
|
|
12
|
+
<button
|
|
13
|
+
class = "btn skin-background-color"
|
|
14
|
+
style = "height: 100%; margin-right: 0 !important;"
|
|
15
|
+
@click.stop.prevent = "toggled = !toggled"
|
|
16
|
+
>
|
|
17
|
+
<i :class="[g3wtemplate.getFontClass('pencil')]"></i>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
`,
|
|
21
|
+
|
|
22
|
+
name: "DrawInputVectorFeatures",
|
|
23
|
+
props: {
|
|
24
|
+
datatypes: {
|
|
25
|
+
type: Array, //array of datatypes from input
|
|
26
|
+
default: []
|
|
27
|
+
},
|
|
28
|
+
upload:{
|
|
29
|
+
type: Boolean, //Boolean when file is upload ot not
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
toggled: false, //draw button toggled
|
|
35
|
+
drawTool: {
|
|
36
|
+
loading: this.upload,
|
|
37
|
+
disabled: true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
/**
|
|
43
|
+
* handle draw interaction flow
|
|
44
|
+
*/
|
|
45
|
+
setDrawInteraction(type=this.drawGeometryTypes[0]){
|
|
46
|
+
GUI.getService('map').disableClickMapControls(true); // avoid click conflicts
|
|
47
|
+
this.drawLayer.getSource().clear(); // clear previous features
|
|
48
|
+
GUI.getService('map').getMap().removeInteraction(this.drawInteraction); // remove previous draw interaction
|
|
49
|
+
this.drawInteraction = new ol.interaction.Draw({ type, source: this.drawLayer.getSource() }); // create draw interaction
|
|
50
|
+
this.drawInteraction.on('drawend', () => this.drawTool.disabled = false); // enable upload button on drawend
|
|
51
|
+
GUI.getService('map').getMap().addInteraction(this.drawInteraction); // add interaction to Map
|
|
52
|
+
},
|
|
53
|
+
clear() {
|
|
54
|
+
this.drawLayer.getSource().clear();
|
|
55
|
+
GUI.getService('map').disableClickMapControls(false);
|
|
56
|
+
GUI.getService('map').getMap().removeInteraction(this.drawInteraction);
|
|
57
|
+
GUI.closeUserMessage();
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
watch: {
|
|
61
|
+
//listen toggled button
|
|
62
|
+
toggled(bool){
|
|
63
|
+
if (!bool) {
|
|
64
|
+
this.clear();
|
|
65
|
+
this.$emit('toggled-tool', !bool);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
//set start interaction
|
|
69
|
+
this.setDrawInteraction();
|
|
70
|
+
//whow tool component
|
|
71
|
+
GUI.showUserMessage({
|
|
72
|
+
title: '', //@TODO add translation title
|
|
73
|
+
type: 'tool',
|
|
74
|
+
size: 'small',
|
|
75
|
+
closable: false,
|
|
76
|
+
hooks: {
|
|
77
|
+
body: {
|
|
78
|
+
template: /* html */`
|
|
79
|
+
<div style="width: 100%; padding: 5px;" v-disabled="state.loading">
|
|
80
|
+
<!-- NB: it makes use of built-in g3w-client directive: "v-select2" -->
|
|
81
|
+
<select
|
|
82
|
+
v-select2 = "'type'"
|
|
83
|
+
:search = "false"
|
|
84
|
+
ref = "select"
|
|
85
|
+
style = "width: 100%">
|
|
86
|
+
<option
|
|
87
|
+
v-for = "type in types"
|
|
88
|
+
:key = "type"
|
|
89
|
+
:value = "type"
|
|
90
|
+
v-t-plugin = "'qprocessing.draw_types.'+type"
|
|
91
|
+
></option>
|
|
92
|
+
</select>
|
|
93
|
+
|
|
94
|
+
<bar-loader :loading="state.loading"/>
|
|
95
|
+
|
|
96
|
+
<button
|
|
97
|
+
v-disabled="state.disabled"
|
|
98
|
+
class="btn skin-background-color"
|
|
99
|
+
@click.stop.prevent="uploadLayer(type)"
|
|
100
|
+
style="margin: 3px; width: 100%">
|
|
101
|
+
<i :class="[g3wtemplate.getFontClass('cloud-upload')]"></i>
|
|
102
|
+
</button>
|
|
103
|
+
|
|
104
|
+
</div>`,
|
|
105
|
+
data: () => {
|
|
106
|
+
return {
|
|
107
|
+
state: this.drawTool,
|
|
108
|
+
types: this.drawGeometryTypes,
|
|
109
|
+
type: this.drawGeometryTypes[0]
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
watch: {
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @listens type change of drawed geometry
|
|
116
|
+
* @fires change-draw-type
|
|
117
|
+
*/
|
|
118
|
+
'type': (type) => {
|
|
119
|
+
this.setDrawInteraction(type);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
},
|
|
123
|
+
methods: {
|
|
124
|
+
uploadLayer: async (type) => {
|
|
125
|
+
const qprocessing = g3wsdk.core.plugin.PluginsRegistry.getPlugin('qprocessing');
|
|
126
|
+
const features = this.drawLayer.getSource().getFeatures();
|
|
127
|
+
await this.$nextTick();
|
|
128
|
+
//emit event
|
|
129
|
+
this.$emit('add-layer', {
|
|
130
|
+
file: qprocessing.createGeoJSONFile({
|
|
131
|
+
features,
|
|
132
|
+
name: `${tPlugin('qprocessing.draw_filename')}(${tPlugin('qprocessing.draw_types.'+type)})`
|
|
133
|
+
}),
|
|
134
|
+
features,
|
|
135
|
+
type: 'draw'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
this.$emit('toggled-tool', !bool);
|
|
143
|
+
},
|
|
144
|
+
upload(bool){
|
|
145
|
+
//listen upload status. Boolean
|
|
146
|
+
this.drawTool.loading = bool;
|
|
147
|
+
this.drawTool.disabled = !bool;
|
|
148
|
+
if (!bool) {
|
|
149
|
+
this.clear();
|
|
150
|
+
this.toggled = bool;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
created() {
|
|
155
|
+
|
|
156
|
+
//set geometries type
|
|
157
|
+
this.drawGeometryTypes = Object.entries({
|
|
158
|
+
point: 'Point',
|
|
159
|
+
line: 'LineString',
|
|
160
|
+
polygon: 'Polygon'
|
|
161
|
+
}).reduce((accumulator, [type, olGeometry]) => {
|
|
162
|
+
if (this.datatypes.find(datatype => datatype === 'anygeometry')){
|
|
163
|
+
accumulator.push(olGeometry);
|
|
164
|
+
} else {
|
|
165
|
+
this.datatypes.find(datatype => datatype === type) && accumulator.push(olGeometry)
|
|
166
|
+
}
|
|
167
|
+
return accumulator;
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
170
|
+
this.drawInteraction = null;
|
|
171
|
+
this.drawLayer = new ol.layer.Vector({ source: new ol.source.Vector() });
|
|
172
|
+
GUI.getService('map').getMap().addLayer(this.drawLayer);
|
|
173
|
+
},
|
|
174
|
+
beforeDestroy() {
|
|
175
|
+
this.clear();
|
|
176
|
+
GUI.getService('map').getMap().removeLayer(this.drawLayer);
|
|
177
|
+
this.drawLayer = null;
|
|
178
|
+
this.drawInteraction = null;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
const { selectMixin } = g3wsdk.gui.vue.Mixins;
|
|
2
|
+
const { XHR } = g3wsdk.core.utils;
|
|
3
|
+
const { ProjectsRegistry } = g3wsdk.core.project;
|
|
4
|
+
|
|
5
|
+
export default ({
|
|
6
|
+
|
|
7
|
+
// language=html
|
|
8
|
+
template: /* html */ `
|
|
9
|
+
<div
|
|
10
|
+
v-if = "state.visible"
|
|
11
|
+
class = "form-group field-chooser"
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
<slot name="label">
|
|
15
|
+
<label :for="state.name" v-disabled="!state.editable" class="col-sm-12">
|
|
16
|
+
{{ state.label }}
|
|
17
|
+
<span v-if="state.validate && state.validate.required">*</span>
|
|
18
|
+
</label>
|
|
19
|
+
</slot>
|
|
20
|
+
|
|
21
|
+
<div class="col-sm-12">
|
|
22
|
+
|
|
23
|
+
<slot name="body">
|
|
24
|
+
<bar-loader :loading="loading"/>
|
|
25
|
+
<select
|
|
26
|
+
v-select2 = "'value'"
|
|
27
|
+
:multiple = "state.input.options.multiple"
|
|
28
|
+
:id = "state.name"
|
|
29
|
+
ref = "select"
|
|
30
|
+
style = "width:100%;"
|
|
31
|
+
class = "form-control"
|
|
32
|
+
>
|
|
33
|
+
<option
|
|
34
|
+
v-if = "state.validate.required && !state.input.options.multiple"
|
|
35
|
+
:value = "null"
|
|
36
|
+
>---</option>
|
|
37
|
+
<option
|
|
38
|
+
v-for = "value in state.input.options.values"
|
|
39
|
+
:selected = "state.input.options.default_to_all_fields"
|
|
40
|
+
:key ="value.value"
|
|
41
|
+
:value = "value.value"
|
|
42
|
+
>{{ value.key }}</option>
|
|
43
|
+
</select>
|
|
44
|
+
</slot>
|
|
45
|
+
|
|
46
|
+
<slot name="message">
|
|
47
|
+
<p
|
|
48
|
+
v-if = "notvalid"
|
|
49
|
+
class = "g3w-long-text error-input-message"
|
|
50
|
+
style = "margin: 0"
|
|
51
|
+
v-t-plugin = "state.validate.message"
|
|
52
|
+
></p>
|
|
53
|
+
<p
|
|
54
|
+
v-else-if = "state.info"
|
|
55
|
+
style = "margin: 0 "
|
|
56
|
+
v-html = "state.info"
|
|
57
|
+
></p>
|
|
58
|
+
</slot>
|
|
59
|
+
|
|
60
|
+
<div
|
|
61
|
+
v-if = "state.help && this.state.help.visible"
|
|
62
|
+
v-html = "state.help.message"
|
|
63
|
+
class = "g3w_input_help skin-background-color extralighten"
|
|
64
|
+
></div>
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
`,
|
|
70
|
+
|
|
71
|
+
name: "InputFieldChooser",
|
|
72
|
+
|
|
73
|
+
mixins: [selectMixin],
|
|
74
|
+
|
|
75
|
+
props: {
|
|
76
|
+
state: {
|
|
77
|
+
type: Object,
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
loading: false,
|
|
86
|
+
value: this.state.input.options.multiple ? [] : null,
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
computed: {
|
|
91
|
+
notvalid(){
|
|
92
|
+
return this.state.validate.valid === false;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
watch: {
|
|
97
|
+
//listen change of value (input select)
|
|
98
|
+
'value'(value) {
|
|
99
|
+
// in case of multiple selection
|
|
100
|
+
if (this.state.input.options.multiple) {
|
|
101
|
+
//set input value as values separate by comma
|
|
102
|
+
this.state.value = value.join(',');
|
|
103
|
+
//check if is required
|
|
104
|
+
if (true === this.state.validate.required) {
|
|
105
|
+
//need to check validation
|
|
106
|
+
this.state.validate.valid = value.length > 0;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
//case single value
|
|
110
|
+
this.state.value = value;
|
|
111
|
+
// in case of required input value
|
|
112
|
+
if (true === this.state.validate.required) {
|
|
113
|
+
this.state.validate.valid = "" !== value && null !== value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//emit change input
|
|
117
|
+
this.$emit('changeinput', this.state);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
methods: {
|
|
122
|
+
/**
|
|
123
|
+
* Method to extract fields from project layerId based on options
|
|
124
|
+
*
|
|
125
|
+
* @param layerId
|
|
126
|
+
* @param options: <Object> datatype
|
|
127
|
+
*/
|
|
128
|
+
async _getFieldsFromLayer(layerId, params={}) {
|
|
129
|
+
const qprocessing = g3wsdk.core.plugin.PluginsRegistry.getPlugin('qprocessing');
|
|
130
|
+
|
|
131
|
+
// Check if it already fills by layerId
|
|
132
|
+
if (undefined === qprocessing.layerFields[layerId]) {
|
|
133
|
+
qprocessing.layerFields[layerId] = {};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// check if it was fill based on params
|
|
137
|
+
const GIVE_ME_A_NAME = qprocessing.layerFields[layerId][JSON.stringify(params)];
|
|
138
|
+
|
|
139
|
+
//check if layerId belong to project layer or is id of temporary upload layer
|
|
140
|
+
if (undefined === GIVE_ME_A_NAME && undefined === ProjectsRegistry.getCurrentProject().getLayers().find(layer => layer.id === layerId)) {
|
|
141
|
+
qprocessing.layerFields[layerId][JSON.stringify(params)] = [];
|
|
142
|
+
} else if (undefined === GIVE_ME_A_NAME) {
|
|
143
|
+
try {
|
|
144
|
+
//do request to api
|
|
145
|
+
const response = await XHR.get({
|
|
146
|
+
url: `${qprocessing.config.urls.fields}${ProjectsRegistry.getCurrentProject().getId()}/${layerId}/`,
|
|
147
|
+
params
|
|
148
|
+
});
|
|
149
|
+
if (true === response.result) {
|
|
150
|
+
qprocessing.layerFields[layerId][JSON.stringify(params)] = response.fields;
|
|
151
|
+
}
|
|
152
|
+
} catch(err) {
|
|
153
|
+
console.warn(err);
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return qprocessing.layerFields[layerId][JSON.stringify(params)];
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Get all fields by layers
|
|
162
|
+
* @param layerId
|
|
163
|
+
* @param options
|
|
164
|
+
* @returns {*}
|
|
165
|
+
*/
|
|
166
|
+
async getFieldsFromLayer(layerId, options={}){
|
|
167
|
+
this.loading = true;
|
|
168
|
+
const fields = await this._getFieldsFromLayer(layerId, options);
|
|
169
|
+
this.loading = false;
|
|
170
|
+
return fields;
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
created() {
|
|
175
|
+
//set it true at beginning to reactivity
|
|
176
|
+
this.state.validate.valid = true;
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
async mounted() {
|
|
180
|
+
//if required we set message of not valid input
|
|
181
|
+
if (this.state.validate.required) {
|
|
182
|
+
this.state.validate.message = `qprocessing.inputs.fieldchooser.validate.message.${this.state.input.options.multiple ? 'multiple' : 'single'}`
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
await this.$nextTick();
|
|
186
|
+
//set this.select2 element
|
|
187
|
+
this.select2 = $(this.$refs.select);
|
|
188
|
+
|
|
189
|
+
//emit register change input to listen parent input layer value and get related fields
|
|
190
|
+
this.$emit('register-change-input', {
|
|
191
|
+
inputName: this.state.input.options.parent_field,
|
|
192
|
+
handler: async (layerId) => {
|
|
193
|
+
//in case of change parent value change, in case of selectefeature need to get only layerId without featuresid
|
|
194
|
+
layerId = layerId.split(':')[0];
|
|
195
|
+
//set values from Input layer fields
|
|
196
|
+
this.state.input.options.values = await this.getFieldsFromLayer(layerId, {
|
|
197
|
+
datatype: this.state.input.options.datatype,
|
|
198
|
+
})
|
|
199
|
+
//check if multiple
|
|
200
|
+
if (this.state.input.options.multiple) {
|
|
201
|
+
//value is set checking if default_all_fields is true, set all options values by defaults, otherwise empty array
|
|
202
|
+
this.value = this.state.input.options.default_to_all_fields ? this.state.input.options.values.map(({value}) => value) : [];
|
|
203
|
+
} else {
|
|
204
|
+
this.value = null;
|
|
205
|
+
}
|
|
206
|
+
// in case of no value or values set value to null
|
|
207
|
+
if (this.value === null || (Array.isArray(this.value) && this.value.length === 0)) {
|
|
208
|
+
this.select2.val(null).trigger('change');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
this.state.validate.valid = !this.state.validate.required;
|
|
214
|
+
//emit add input
|
|
215
|
+
this.$emit('addinput', this.state);
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
document.head.insertAdjacentHTML(
|
|
220
|
+
'beforeend',
|
|
221
|
+
/* css */`
|
|
222
|
+
<style>
|
|
223
|
+
/* Replicate same scoped style in InputBase.vue */
|
|
224
|
+
.field-chooser label { text-align: left !important; padding-top: 0 !important; margin-bottom: 3px; }
|
|
225
|
+
</style>`,
|
|
226
|
+
);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const { selectMixin } = g3wsdk.gui.vue.Mixins;
|
|
2
|
+
const { ProjectsRegistry } = g3wsdk.core.project;
|
|
3
|
+
|
|
4
|
+
export default ({
|
|
5
|
+
|
|
6
|
+
// language=html
|
|
7
|
+
template: /* html */ `
|
|
8
|
+
<div
|
|
9
|
+
v-if = "state.visible"
|
|
10
|
+
class = "form-group prj-raster-layer"
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
<slot name="label">
|
|
14
|
+
<label
|
|
15
|
+
:for = "state.name"
|
|
16
|
+
v-disabled = "!state.editable"
|
|
17
|
+
class = "col-sm-12">
|
|
18
|
+
>
|
|
19
|
+
{{ state.label }}
|
|
20
|
+
<span v-if="state.validate && state.validate.required">*</span>
|
|
21
|
+
</label>
|
|
22
|
+
</slot>
|
|
23
|
+
|
|
24
|
+
<div class="col-sm-12">
|
|
25
|
+
|
|
26
|
+
<slot name="body">
|
|
27
|
+
<select
|
|
28
|
+
v-select2 = "'value'"
|
|
29
|
+
:id = "state.name"
|
|
30
|
+
ref = "select"
|
|
31
|
+
style = "width:100%;"
|
|
32
|
+
class = "form-control"
|
|
33
|
+
>
|
|
34
|
+
<option
|
|
35
|
+
v-for = "value in state.input.options.values"
|
|
36
|
+
:key = "value.value"
|
|
37
|
+
:value = "value.value"
|
|
38
|
+
>{{ value.key }}</option>
|
|
39
|
+
</select>
|
|
40
|
+
</slot>
|
|
41
|
+
|
|
42
|
+
<slot name="message">
|
|
43
|
+
<p
|
|
44
|
+
v-if = "notvalid"
|
|
45
|
+
v-html = "state.validate.message"
|
|
46
|
+
class = "g3w-long-text error-input-message"
|
|
47
|
+
style = "margin: 0"
|
|
48
|
+
></p>
|
|
49
|
+
<p
|
|
50
|
+
v-else-if = "state.info"
|
|
51
|
+
v-html = "state.info"
|
|
52
|
+
style = "margin: 0"
|
|
53
|
+
></p>
|
|
54
|
+
</slot>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
v-if = "state.help && this.state.help.visible"
|
|
58
|
+
v-html = "state.help.message"
|
|
59
|
+
class = "g3w_input_help skin-background-color extralighten"
|
|
60
|
+
></div>
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
`,
|
|
66
|
+
|
|
67
|
+
name: "InputPrjRasterLayer",
|
|
68
|
+
mixins: [selectMixin],
|
|
69
|
+
props: {
|
|
70
|
+
state: {
|
|
71
|
+
type: Object,
|
|
72
|
+
required: true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
data(){
|
|
76
|
+
return {
|
|
77
|
+
value: null,
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
computed: {
|
|
81
|
+
//recreate same computed property of input editing
|
|
82
|
+
notvalid() {
|
|
83
|
+
return this.state.validate.valid === false;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
watch: {
|
|
87
|
+
//listen change of value (input select)
|
|
88
|
+
'value'(value) {
|
|
89
|
+
this.state.value = value;
|
|
90
|
+
this.$emit('changeinput', this.state);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
created() {
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get all Project Vector Layers that has geometry types
|
|
97
|
+
* @param datatypes <Array> of String
|
|
98
|
+
* 'nogeometry',
|
|
99
|
+
* 'point',
|
|
100
|
+
* 'line',
|
|
101
|
+
* 'polygon',
|
|
102
|
+
* 'anygeometry'
|
|
103
|
+
* return <Array>
|
|
104
|
+
*/
|
|
105
|
+
this.state.input.options.values = ProjectsRegistry.getCurrentProject().getLayers()
|
|
106
|
+
//exclude base layer
|
|
107
|
+
.filter(layer => !layer.baselayer && (undefined !== layer.source && layer.source.type === 'gdal'))
|
|
108
|
+
.map(layer => ({
|
|
109
|
+
key: layer.name,
|
|
110
|
+
value: layer.id
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
if (this.state.input.options.values.length > 0) {
|
|
114
|
+
//set initial value
|
|
115
|
+
this.value = this.state.input.options.values[0].value;
|
|
116
|
+
this.state.validate.valid = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
},
|
|
120
|
+
async mounted(){
|
|
121
|
+
await this.$nextTick();
|
|
122
|
+
//set select2 needed to selectMixin
|
|
123
|
+
this.select2 = $(this.$refs.select);
|
|
124
|
+
this.$emit('addinput', this.state);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
document.head.insertAdjacentHTML(
|
|
129
|
+
'beforeend',
|
|
130
|
+
/* css */`
|
|
131
|
+
<style>
|
|
132
|
+
/* Replicate same scoped style in InputBase.vue */
|
|
133
|
+
.prj-raster-layer label { text-align: left !important; padding-top: 0 !important; margin-bottom: 3px; }
|
|
134
|
+
</style>`,
|
|
135
|
+
);
|