diff --git a/pom.xml b/pom.xml index 74b2a87..b563e67 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.flowingcode.vaadin.addons orgchart-addon - 4.2.3-SNAPSHOT + 5.0.0-SNAPSHOT OrgChart Add-on @@ -192,10 +192,7 @@ apache_v2 false - **/font-awesome.css - **/jquery.orgchart.js - **/jquery.orgchart.min.js - **/jquery.orgchart.min.css + **/font-awesome.css @@ -290,6 +287,7 @@ + org.apache.maven.plugins maven-javadoc-plugin diff --git a/src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChart.java b/src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChart.java index f6ac884..9699bce 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChart.java +++ b/src/main/java/com/flowingcode/vaadin/addons/orgchart/OrgChart.java @@ -28,9 +28,9 @@ import com.vaadin.flow.component.ComponentEvent; import com.vaadin.flow.component.ComponentEventListener; import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dependency.JsModule; import com.vaadin.flow.component.dependency.NpmPackage; -import com.vaadin.flow.component.dependency.StyleSheet; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.shared.Registration; import java.util.List; @@ -45,14 +45,15 @@ * @author pbartolo */ @SuppressWarnings("serial") -// @NpmPackage(value = "orgchart", version = "2.1.4") -@NpmPackage(value = "html2canvas", version = "^0.5.0-beta4") -@NpmPackage(value = "jquery", version = "3.4.1") +@NpmPackage(value = "orgchart", version = "3.7.0") +@NpmPackage(value = "html2canvas", version = "1.4.1") +@NpmPackage(value = "jquery", version = "3.6.2") @JsModule("jquery/dist/jquery.js") -@JsModule("./orgchart/dist/js/jquery.orgchart.js") -@StyleSheet("context://frontend/jquery.orgchart.min.css") +@JsModule("orgchart/dist/js/jquery.orgchart.js") +@CssImport("orgchart/dist/css/jquery.orgchart.min.css") @Tag("fc-orgchart") @JsModule("./fc-orgchart.js") +@CssImport("./fc-orgchart-styles.css") public class OrgChart extends Div { private OrgChartItem orgChartItem; diff --git a/src/main/resources/META-INF/frontend/orgchart/dist/js/jquery.orgchart.js b/src/main/resources/META-INF/frontend/orgchart/dist/js/jquery.orgchart.js deleted file mode 100644 index b9925cf..0000000 --- a/src/main/resources/META-INF/frontend/orgchart/dist/js/jquery.orgchart.js +++ /dev/null @@ -1,1424 +0,0 @@ -/* - * jQuery OrgChart Plugin - * https://github.com/dabeng/OrgChart - * - * Copyright 2016, dabeng - * https://github.com/dabeng - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/MIT - */ -'use strict'; - -import jQuery from "jquery"; - -(function (factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - factory(jQuery, window, document); - } else { - factory(jQuery, window, document); - } -}(function ($, window, document, undefined) { - var OrgChart = function (elem, opts) { - this.$chartContainer = $(elem); - this.opts = opts; - this.defaultOptions = { - 'nodeTitle': 'name', - 'nodeId': 'id', - 'toggleSiblingsResp': false, - 'visibleLevel': 999, - 'chartClass': '', - 'exportButton': false, - 'exportFilename': 'OrgChart', - 'exportFileextension': 'png', - 'parentNodeSymbol': 'fa-users', - 'draggable': false, - 'direction': 't2b', - 'pan': false, - 'zoom': false, - 'zoominLimit': 7, - 'zoomoutLimit': 0.5 - }; - }; - // - OrgChart.prototype = { - // - init: function (opts) { - var that = this; - this.options = $.extend({}, this.defaultOptions, this.opts, opts); - // build the org-chart - var $chartContainer = this.$chartContainer; - if (this.$chart) { - this.$chart.remove(); - } - var data = this.options.data; - var $chart = this.$chart = $('
', { - 'data': { 'options': this.options }, - 'class': 'orgchart' + (this.options.chartClass !== '' ? ' ' + this.options.chartClass : '') + (this.options.direction !== 't2b' ? ' ' + this.options.direction : ''), - 'click': function(event) { - if (!$(event.target).closest('.node').length) { - $chart.find('.node.focused').removeClass('focused'); - } - } - }); - if (typeof MutationObserver !== 'undefined') { - this.triggerInitEvent(); - } - if ($.type(data) === 'object') { - if (data instanceof $) { // ul datasource - this.buildHierarchy($chart, this.buildJsonDS(data.children()), 0, this.options); - } else { // local json datasource - this.buildHierarchy($chart, this.options.ajaxURL ? data : this.attachRel(data, '00')); - } - } else { - $chart.append(''); - $.ajax({ - 'url': data, - 'dataType': 'json' - }) - .done(function(data, textStatus, jqXHR) { - that.buildHierarchy($chart, that.options.ajaxURL ? data : that.attachRel(data, '00'), 0, that.options); - }) - .fail(function(jqXHR, textStatus, errorThrown) { - console.log(errorThrown); - }) - .always(function() { - $chart.children('.spinner').remove(); - }); - } - $chartContainer.append($chart); - - // append the export button - if (this.options.exportButton && !$chartContainer.find('.oc-export-btn').length) { - this.attachExportButton(); - } - - if (this.options.pan) { - this.bindPan(); - } - - if (this.options.zoom) { - this.bindZoom(); - } - - return this; - }, - // - triggerInitEvent: function () { - var that = this; - var mo = new MutationObserver(function (mutations) { - mo.disconnect(); - initTime: - for (var i = 0; i < mutations.length; i++) { - for (var j = 0; j < mutations[i].addedNodes.length; j++) { - if (mutations[i].addedNodes[j].classList.contains('orgchart')) { - if (that.options.initCompleted && typeof that.options.initCompleted === 'function') { - that.options.initCompleted(that.$chart); - var initEvent = $.Event('init.orgchart'); - that.$chart.trigger(initEvent); - break initTime; - } - } - } - } - }); - mo.observe(this.$chartContainer[0], { childList: true }); - }, - // - attachExportButton: function () { - var that = this; - var $exportBtn = $('