Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Raruto authored Feb 11, 2025
2 parents 2e3a121 + b2159b9 commit 98d8890
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 74 deletions.
10 changes: 8 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ const dev_plugins = Array.from(
function get_version(pluginName) {
const src = (pluginName ? `${g3w.pluginsFolder}/${pluginName}` : '.');
// delete cache of require otherwise no package.json version rests the old (cache) one
delete require.cache[require.resolve(`${src}/package.json`)];
try {
delete require.cache[require.resolve(`${src}/package.json`)];
} catch (e) {
console.warn(YELLOW__ + '[WARN] ' + __RESET + 'package.json not found (' + GREEN__ + pluginName + __RESET + ')');
}
try {
return require(`${src}/package.json`).version;
} catch(e) {
Expand Down Expand Up @@ -159,7 +163,9 @@ const build_plugin = async (pluginName) => {
name: 'onBuildEnd',
setup(build) {
build.onEnd(result => {
console.log(GREEN__ + '[' + pluginName + ']' + __RESET + ' → ' + Math.round(fs.statSync(`${outputFolder}/plugin.js`).size / 1024) + 'KB')
console.log(GREEN__ + '[' + pluginName + ']' + __RESET + ' → ' + Math.round(fs.statSync(`${outputFolder}plugin.js`).size / 1024) + 'KB');
// Add "plugin.js" to git repository (eg. ./src/editing/plugin.js)
fs.cpSync(`${outputFolder}plugin.js`, `${g3w.pluginsFolder}/${pluginName}/plugin.js`);
resolve();
})
},
Expand Down
19 changes: 9 additions & 10 deletions src/components/Catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,13 @@
<!-- ORIGINAL SOURCE: src/components/[email protected] -->
<!-- ORIGINAL SOURCE: src/components/[email protected] -->
<div
v-if = "'tab' === legend_position"
v-if = "'tab' === legend_position && 'legend' === activeTab"
v-for = "tree in state.layerstrees"
:key = "tree.id"
role = "tabpanel"
id = "legend"
class = "tab-pane"
:style = "{ backgroundColor: backgroundLegend }"
:class = "{ active: 'legend' === activeTab }"
>
<div v-for = "t in tree.tree" class = "legend-item"> <!-- TODO: check if such nesting level really necessary.. -->
Expand Down Expand Up @@ -317,6 +318,7 @@ export default {
legend_position: ApplicationState.project.state.legend_position || 'tab',
iframe: ApplicationState.iframe,
showlegend: false,
backgroundLegend: ApplicationState.gui.layout.app.legend && ApplicationState.gui.layout.app.legend.transparent ? 'transparent' : '#FFFFFF', //@since 3.11.3 set transparent or white background
currentBaseLayer: null,
activeTab: 'layers',
loading: false,
Expand Down Expand Up @@ -367,13 +369,13 @@ export default {

methods: {

onLegendError(legendurl) {
legendurl.error = true;
legendurl.loading = false;
onLegendError(url) {
url.error = true;
url.loading = false;
},

onLegendLoad(legendurl) {
legendurl.loading = false;
onLegendLoad(url) {
url.loading = false;
},

/**
Expand Down Expand Up @@ -519,12 +521,9 @@ export default {
} catch (e) {
console.warn(e);
}

obj.loading = false;
}
}

return legendurls;
return legendurls;
},

/**
Expand Down
110 changes: 84 additions & 26 deletions src/components/Relation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,55 @@
state: null,
config: { downloads: [] },
},
//@since 3.11.2
page: 1,
page_size: PAGELENGTHS[0],
start: 0,
table: { rows: [] },
nmRelation: ApplicationState.project.getRelationById(this.relation.nmRelationId),

/**
* @since 3.11.2
*/
page: 1,

/**
* @since 3.11.2
*/
page_size: PAGELENGTHS[0],

/**
* @since 3.11.2
*/
start: 0,

/**
* @since 3.11.2
*/
table: {
rows: [],
},

/**
* @type { string | null } parameter sent to server
* @since 3.11.3
*/
ordering: null,

/**
* @type { "desc" | "asc" | "current" } column order
* @since 3.11.3
*/
sort: 'asc',

/**
* @type { number } current column index
* @since 3.11.3
*/
sort_column: 0,

/**
* @since 3.11.2
*/
nmRelation: ApplicationState.project.getRelationById(this.relation.nmRelationId),

/**
* @since 3.11.2
*/
showChartButton: !!this.chartRelationIds.find(id => id === this.relation.referencingLayer),
};
},
Expand Down Expand Up @@ -347,6 +390,7 @@
async getRelationDataTable({
page,
page_size,
ordering
} = {}) {
GUI.setLoadingContent(true);
let table = { rows: [] };
Expand All @@ -360,15 +404,16 @@
relation: this.relation,
page,
page_size,
ordering,
})
}); // get relations
features = response.result ? (response.vector.data.features || []).map(f => {
f.properties[G3W_FID] = f.id;
return {
geometry: f.geometry,
attributes: f.properties,
id: f.id,
};
f.properties[G3W_FID] = f.id;
return {
geometry: f.geometry,
attributes: f.properties,
id: f.id,
};
}) : null;
const count = features && response.vector.count;
if (this.nmRelation) {
Expand Down Expand Up @@ -454,7 +499,7 @@
bLengthChange: true,
dom: 'ltip',
columnDefs: [ this.showTools ? { orderable: false, targets: 0, width: '1%' } : { orderable: true, targets: 0 }],
order: [ this.showTools ? 1 : 0, 'asc' ],
order: [ this.sort_column + !!this.showTools, this.sort],
lengthMenu: PAGELENGTHS,
pageLength: this.page_size,
displayStart: this.start,
Expand All @@ -465,20 +510,27 @@
deferLoading: data_from_server && this.table.count,
ajax: data_from_server ? async (opts) => {
try {
//Need to destroy table
// Destroy table
this.relationDataTable.destroy(true);
this.relationDataTable = null;
//need to change table row to empty
this.table.rows = [];
//wait next tick
await this.$nextTick();
//set len start
this.page_size = opts.length;
this.start = opts.start;
this.table = await this.getRelationDataTable({
page: 0 === opts.start ? 1 : (opts.start/opts.length) + 1,
// check if there is a change (page or number of rows)
const changed = opts.length !== this.page_size || opts.start !== this.start;
// set len start
this.page_size = opts.length;
this.start = opts.start;
const column = opts.order[0].column - !!this.showTools;
const sort = column === this.sort_column ? (changed ? this.sort : ('desc' === this.sort ? 'asc' : 'desc') ) : 'asc';
this.sort_column = column;
this.sort = sort;
// send parameter to server ("-" = descending )
this.ordering = `${'desc' === sort ? '-' : ''}${this.table.fields[opts.order[0].column - !!this.showTools].name}`;
this.table = await this.getRelationDataTable({
page: 1 + (0 !== opts.start ? (opts.start/opts.length) : 0),
page_size: opts.length,
})
ordering: this.ordering
});
} catch(e) {
console.warn(e);
}
Expand Down Expand Up @@ -734,10 +786,16 @@
},

async created() {
this.table = await this.getRelationDataTable({
page: this.page,
page_size: this.page_size,
});
try {
this.table = await this.getRelationDataTable({
page: this.page,
page_size: this.page_size,
ordering: this.ordering,
});
} catch(e) {
console.warn(e);
}

},

/**
Expand Down
69 changes: 37 additions & 32 deletions src/map/layers/imagelayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { get_legend_params } from 'utils/get_legend_params';
* @returns { string | null } a string if value is set or null
*/
function __(name, value) {
return (value || 0 === value) ? `${name}${value}` : null;
return [null, undefined].includes(value) ? value : `${name}${value}`;
}

/**
Expand Down Expand Up @@ -660,7 +660,7 @@ class ImageLayer extends GeoLayerMixin(Layer) {
return (
source && (
('map' !== type || (this.isExternalWMS() && this.isLayerProjectionASMapProjection())) &&
('legend' === type || source.external)
('legend' !== type || source.external)
)
);
}
Expand Down Expand Up @@ -823,7 +823,7 @@ class ImageLayer extends GeoLayerMixin(Layer) {
*
* @see https://docs.qgis.org/3.28/en/docs/server_manual/services/wms.html#getlegendgraphics
*/
getLegendUrl(params = {}, opts = {categories:false, all:false,format:'image/png',}) {
getLegendUrl(params = {}, opts = { categories:false, all:false,format:'image/png',}) {

let base_url, url_params;

Expand All @@ -845,7 +845,10 @@ class ImageLayer extends GeoLayerMixin(Layer) {
layerfontfamily,
layerfontbold,
itemfontbold,
itemfontsize, //@since 3.11.3
layerfontitalic,
layerfontsize, //@since 3.11.3
showfeaturecount, //@since 3.11.3
itemfontitalic,
rulelabel,
crs,
Expand Down Expand Up @@ -887,35 +890,37 @@ class ImageLayer extends GeoLayerMixin(Layer) {
'SERVICE=WMS',
'VERSION=1.3.0',
'REQUEST=GetLegendGraphic',
__('SLD_VERSION=', sld_version),
__('WIDTH=', width),
__('HEIGHT=', height),
__('FORMAT=', (undefined === opts.format ? 'image/png' : opts.format)),
__('TRANSPARENT=', transparent),
__('ITEMFONTCOLOR=', color),
__('LAYERFONTCOLOR=', color),
__('LAYERTITLE=', layertitle),
__('ITEMFONTSIZE=', fontsize),
__('CRS=', crs),
__('BBOX=', ([false, undefined].includes(opts.all) && bbox && bbox.join(','))),
__('BOXSPACE=', boxspace),
__('LAYERSPACE=', layerspace),
__('LAYERTITLESPACE=', layertitlespace),
__('SYMBOLSPACE=', symbolspace),
__('ICONLABELSPACE=', iconlabelspace),
__('SYMBOLWIDTH=', (opts.categories && 'application/json' === opts.format ? 16 : symbolwidth)),
__('SYMBOLHEIGHT=', (opts.categories && 'application/json' === opts.format ? 16 : symbolheight)),
__('LAYERFONTFAMILY=', layerfontfamily),
__('ITEMFONTFAMILY=', itemfontfamily),
__('LAYERFONTBOLD=', layerfontbold),
__('ITEMFONTBOLD=', itemfontbold),
__('LAYERFONTITALIC=', layerfontitalic),
__('ITEMFONTITALIC=', itemfontitalic),
__('RULELABEL=', rulelabel),
__('LEGEND_ON=', ctx_legend && ctx_legend.LEGEND_ON),
__('LEGEND_OFF=', ctx_legend && ctx_legend.LEGEND_OFF),
__('STYLES=', (opts.categories && 'application/json' === opts.format ? encodeURIComponent(this.getCurrentStyle().name) : undefined)),
__('LAYER=', this.getWMSLayerName({ type: 'legend' }))
__('SLD_VERSION=', sld_version),
__('WIDTH=', width),
__('HEIGHT=', height),
__('FORMAT=', (undefined === opts.format ? 'image/png' : opts.format)),
__('TRANSPARENT=', transparent),
__('ITEMFONTCOLOR=', color),
__('LAYERFONTCOLOR=', color),
__('LAYERTITLE=', layertitle),
__('ITEMFONTSIZE=', itemfontsize || fontsize), //@since 3.11.3 check itemfontsize or fontsize
__('CRS=', crs),
__('BBOX=', ((true === opts.all ? undefined : [false, undefined].includes(opts.all) && bbox && bbox.join(',')))),
__('BOXSPACE=', boxspace),
__('LAYERSPACE=', layerspace),
__('LAYERTITLESPACE=', layertitlespace),
__('SYMBOLSPACE=', symbolspace),
__('ICONLABELSPACE=', iconlabelspace),
__('SYMBOLWIDTH=', (opts.categories && 'application/json' === opts.format ? 16 : symbolwidth)),
__('SYMBOLHEIGHT=', (opts.categories && 'application/json' === opts.format ? 16 : symbolheight)),
__('LAYERFONTFAMILY=', layerfontfamily),
__('ITEMFONTFAMILY=', itemfontfamily),
__('LAYERFONTBOLD=', layerfontbold),
__('ITEMFONTBOLD=', itemfontbold),
__('LAYERFONTITALIC=', layerfontitalic),
__('LAYERFONTSIZE=', layerfontsize), //@since 3.11.3
__('SHOWFEATURECOUNT=', showfeaturecount), //@since 3.11.3
__('ITEMFONTITALIC=', itemfontitalic),
__('RULELABEL=', rulelabel),
__('LEGEND_ON=', ctx_legend && ctx_legend.LEGEND_ON),
__('LEGEND_OFF=', ctx_legend && ctx_legend.LEGEND_OFF),
__('STYLES=', (opts.categories && 'application/json' === opts.format ? encodeURIComponent(this.getCurrentStyle().name) : undefined)),
__('LAYER=', this.getWMSLayerName({ type: 'legend' }))
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function _clearContents() {
if (d.content instanceof Component || d.content instanceof Panel) {
await promisify(d.content.unmount());
} else {
$(GUI.getComponent('contents').parent).empty();
$(g3wsdk.gui.GUI.getComponent('contents').parent).empty();
}
}));
ApplicationState.contentsdata.splice(0, ApplicationState.contentsdata.length);
Expand Down Expand Up @@ -1140,4 +1140,4 @@ export default new (class GUI extends G3WObject {
this._layoutComponents(event);
}

});
});
2 changes: 1 addition & 1 deletion src/services/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class BaseIframeService extends G3WObject {
}
// in case of no response zoom to an initial extent
if (!response.found) {
this.zoomToExtent(this.mapService.project.state.initextent)
this.mapService.zoomToExtent(this.mapService.project.state.initextent)
}
return response;
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/createRelationsUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export function createRelationsUrl({
formatter = 1,
page , //@since 3.11.2
page_size, //@since 3.11.2
ordering, //@since 3.11.3
}) {
return `${ApplicationState.project.getLayerById(
undefined === relation.father
? (layer.id === relation.referencedLayer ? relation.referencingLayer : relation.referencedLayer)
: (layer.id === relation.father ? relation.child : relation.father)
).getUrl(type)}?relationonetomany=${relation.id}|${sanitizeFidFeature(fid)}&formatter=${formatter}${page ? '&page=' + page: ''}${page_size ? '&page_size=' + page_size: ''}`;
).getUrl(type)}?relationonetomany=${relation.id}|${sanitizeFidFeature(fid)}&formatter=${formatter}${page ? '&page=' + page: ''}${page_size ? '&page_size=' + page_size: ''} ${ordering ? '&ordering=' + ordering: ''}`;
}

0 comments on commit 98d8890

Please sign in to comment.