ForgeKomponenty
pl

Komponenty

j-Flow

jComponent 20 · jcomponent@20 component Przykład załadowany z jComponent 20
  • - identyfikator nie może zawierać __

Konfiguracja:

  • width {Number} szerokość Flow Designer, domyślnie: 6000
  • height {Number} wysokość Flow Designer, standard: 6000
  • grid {Number} wielkość sieci tła, domyślnie: 25
  • Wstępne podkładki paddingX {Number}: 6
  • curvedlines {Boolean} umożliwia zakrzywione linie, standardowe: false
  • infopath {String} - ścieżka do zmiennej / metody, odpowiedź: { zoom: Number, selected: Object }
  • undopath {String} - ścieżka do zmiennej / metody, odpowiedź jest obiektem
  • redopath {String} - ścieżka do zmiennej / metody, odpowiedź jest obiektem
  • ondrop {String} Droga do metody fn(dropmeta, grid)
  • Ścieżka onmake {String} do metody fn(el, com), wykonuje się, gdy składnik jest tworzony
  • Ścieżka ondone {String} do metody fn(el, com), wykonuje się, gdy składnik jest utworzony
  • Ścieżka onmove {String} do metody fn(el, com/group, type), jest wykonywana, gdy składnik/grupa się porusza
  • Ścieżka onremove {String} do metody fn(el, com), wykonuje się, gdy składnik jest usunięty
  • Ścieżka onconnect {String} do metody fn(meta), jest wykonywana, gdy dwa komponenty są połączone
  • Ścieżka ondisconnect {String} do metody fn(meta), jest wykonywana, gdy dwa elementy są odłączone
  • NEW onpause {String} jest ścieżką do metody fn(path, is), wykonuje się, gdy wyjście / wejście jest przerwane
  • steplines {Boolean} umożliwia linie krokowe (default: false)
  • Promień animacji animationradius {Number} w pikselach (default: 5)
  • contextmenu {String} jest drogą do function(e, type, component/meta) (typ może być map, component, connection, group)
  • dblclick {String} - droga do function(component)
  • outputoffsetX {Number} zwykła opcja X dla punktu wyjścia (zwykła: 10)
  • outputoffsetY {Number} zwrotny Y dla punktu wyjścia (zwrotny: 12)
  • inputoffsetX {Number} jest zwykłym opłatą X dla punktu wejściowego (zwykły: 10)
  • inputoffsetY {Number} zwrotny Y dla punktu wejściowego (zwrotny: 12)
  • snapping {Number} w pikselach (default: 0 = wyłączony)
  • multiple {Boolean} umożliwia wielokrotne wybieranie składnika (default: true)
  • history {Number} liczba kroków w historii undo/redo (default: 100)
  • animationlimit {Number} maksymalna liczba punktów dla wszystkich animacji (default: 100)
  • animationlimitconnection {Number} maksymalna liczba punktów na połączenie (default: 5)
  • allowpause {Boolean} umożliwia przerwę na wyjściach / wejściach (default: true)
  • markers {Boolean} dodaje wskaźniki strzał do połączenia (default: true)

polecenia:

  • flow.refresh oblicza pozycje
  • flow.selected.disconnect odłącza wybrane połączenia
  • flow.selected.remove usuwa wybrane elementy
  • flow.selected.clear usuwa wybrany składnik lub połączenie
  • flow.zoom Zaczyna się od zoomu, argument: type (może być to: in, out, reset lub percentage {Number}Drugi argument opcjonalny: percentage
  • flow.undo wykonuje krok
  • flow.redo wykonuje gotowy krok
  • flow.reset edytor
  • flow.components.add dodaje nowy składnik, argument: component_declaration
  • flow.components.find znajduje składnik, argument: component_id
  • flow.clean oczyszcza dane i nieistniejące połączenia
  • flow.traffic(componentid__outputid, { count: 3, speed: 3, limit: 20, delay: 50, reverse: false }) animacja
    • Animacja reverse może zostać uwzględniona poprzez dodanie _ jako początek identyfikatoru _componentid__outputid.
  • NEW flow.groups.find znajduje grupę, argument: group_id
  • NEW flow.check nową szybszą alternatywę dla polecenia flow.refresh
  • NEW flow.find znajduje składnik lub grupę, argument: component_id lub group_id

Dodaj nowy składnik:

  • Komponent automatycznie tworzy identyfikator komponentu
  • connections Jest {Object}
// Component declaration
var component = {
	x: 100,
	y: 50,
	html: 'Component test',

	outputs: ['1 output name', '2 output name'],
	// or
	// outputs: [{ id: 'A', name: 'A output name' }, { id: 'B', name: 'B output name', color: '#FF8E37' }],

	connections: { '0': [{ id: '0002', index: '2', disabled: false }] }, // Look to the connection object below
	// or
	// connections: { 'A': [{ id: '0002', index: 'B', disabled: false }] },

	actions: { select: true, move: true, disabled: false, remove: true, connect: true }
};

// Appends component
CMD('flow.components.add', component);
// Connection object
// connections: { '0': [CONNECTION_OBJECT1, CONNECTION_OBJECT2, CONNECTION_OBJECT3] }
{
	id: 'TARGET_ID_COMPONENT',
	index: '0', // An input index or index id, must be string!!!
	disabled: false // Optional, it's the connection disabled? Disabled connection can't be removed
}

Wydajność przepływu:

  • Powrót Object, które klucze są ID składników
{
	'F1562743923216': { x: 1, y: 1, connections: [], ... },
	'F1562743965303': { x: 1, y: 1, connections: [], ... },

	// Contains paused endpoints
	paused: { 'input__COMPONENTID__INDEXID': 1, 'output__COMPONENTID__INDEXID': 1 },

	// Contains groups
	groups: [{ id: 'GroupID', name: 'Name', x: 100, y: 100, width: 100, height: 100, background: 'rgba(0,0,0,0.1)', color: '#000', border: 'rgba(0,0,0,0.1)' }, ...];
}

Dobrze wiedzieć:

  • Każdy składnik (w przepływie) zawiera klasę f-COMPONENTNAME
  • Klasa selectable w elementie komponentu umożliwia kopiowanie tekstu i zakłóca ruch
  • connections obsługuje type:"transform" z linią

Użyj go z <ui-component name="flow">Gdy element nie jest jeszcze ładowany, jComponent Pobierz go po pierwszym użyciu z adresu DEF.fallback (Wydaje się Componentator Autor: Peter Širka Źródło: Componentator Zestaw składników, licencja MIT.

example.html
<style>
	.toolbar { margin-bottom: 10px; }
	.toolbar button { min-width: 26px; height: 24px; background-color: transparent; border: 0; font-size: 12px; color: gray; }
	.toolbar button span { margin-left: 3px; }
	.toolbar button[name="remove"] { color: red !important; }
	.toolbar button:disabled { color: #C0C0C0 !important; cursor: not-allowed; }
	.toolbar button:hover { color: black; }
	.toolbar button:first-child { border-left: 0; }
</style>

<div class="toolbar">
	<button is="is-button" path="floweditor.undo" config="enabled:value && value.length > 0;click:floweditor_undo" disabled="disabled"><i class="ti ti-undo"></i></button>
	<button is="is-button" path="floweditor.redo" config="enabled:value && value.length > 0;click:floweditor_redo" disabled="disabled"><i class="ti ti-redo"></i></button>
	<button is="is-button" path="floweditor.info.selected" config="enabled;click:floweditor_remove" name="remove" disabled="disabled"><i class="ti ti-trash"></i></button>
</div>

<ui-component name="flow" path="flowmodel" config="width:6000;height:6000;grid:26;infopath:floweditor.info;undopath:floweditor.undo;redopath:floweditor.redo"></ui-component>

<script>

	var flowmodel = {
		groups: [{ id: 'G12345', name: 'My group', x: 50, y: 50, width: 300, height: 300 }],
		'F1562743923216': { x: 100, y: 150, html: 'Component 1', outputs: ['Done', 'Error'], connections: { '0': [{ id: 'F1562743965303', index: '2', disabled: false }] }},
		'F1562743965303': { x: 500, y: 250, html: 'Component 2', inputs: ['1', '2', '3'] }
	};

	var floweditor = {};

	function floweditor_undo() {
		CMD('flow.undo');
	}

	function floweditor_redo() {
		CMD('flow.redo');
	}

	function floweditor_remove() {
		CMD('flow.selected.clear');
	}

	// Extend buttons for using Web components
	customElements.define('is-button', class extends HTMLButtonElement {
		constructor() {
			super();
			setTimeout(NEWUIBIND, 2, this);
		}
	}, { extends: 'button' });

</script>