Sidebar-IndustrialComponent.js 3.65 KB

(function () {
	// Adds Atlassian shapes
	// industrial label
	Sidebar.prototype.addThingsKitIndustrialPalette = function () {

		const gn = 'mxgraph.industrial';
		const dt = 'industrial';
		const label = mxResources.get('industry')
		const width = 66;
		const height = 74;
		const prefix = `image;image=${window?.PROJECT_ENV.base}/webapp/images/thingskit/libs/`
		const defaultStyle = ';imageAspect=0;'
		this.setCurrentSearchEntryLibrary(dt);

		const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum

		function createUserObject(attribute) {
			attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
			var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');

			Object.keys(attribute).forEach(key => {
				xmlElement.setAttribute(key, attribute[key]);
			})
			return xmlElement
		}

		// 自定义属性
		const cellAttribute = {
			[COMPONENT_KEY]: 'Image',
			[CATEGORY]: 'DEFAULT'
		}

		const graphPathLib = [
			{ name: mxResources.get('industry1'), path: 'industrial/三级高速剪切机.svg' },
			{ name: mxResources.get('industry2'), path: 'industrial/二甲氧基甲烷计量罐.svg' },
			{ name: mxResources.get('industry3'), path: 'industrial/传送带.svg' },
			{ name: mxResources.get('industry4'), path: 'industrial/分仓.svg' },
			{ name: mxResources.get('industry5'), path: 'industrial/剪切机.svg' },
			{ name: mxResources.get('industry6'), path: 'industrial/干线管道.svg' },
			{ name: mxResources.get('industry7'), path: 'industrial/干酵母粉仓.svg' },
			{ name: mxResources.get('industry8'), path: 'industrial/成品罐.svg' },
			{ name: mxResources.get('industry9'), path: 'industrial/成熟度.svg' },
			{ name: mxResources.get('industry10'), path: 'industrial/料仓.svg' },
			{ name: mxResources.get('industry11'), path: 'industrial/旋液分离器.svg' },
			{ name: mxResources.get('industry12'), path: 'industrial/智能控制周期.svg' },
			{ name: mxResources.get('industry13'), path: 'industrial/机组.svg' },
			{ name: mxResources.get('industry14'), path: 'industrial/母液槽.svg' },
			{ name: mxResources.get('industry15'), path: 'industrial/母液槽2.svg' },
			{ name: mxResources.get('industry16'), path: 'industrial/沥青混合料槽.svg' },
			{ name: mxResources.get('industry17'), path: 'industrial/沥青膨胀罐.svg' },
			{ name: mxResources.get('industry18'), path: 'industrial/泄料桶.svg' },
			{ name: mxResources.get('industry19'), path: 'industrial/消烟管.svg' },
			{ name: mxResources.get('industry20'), path: 'industrial/涡轮.svg' },
			{ name: mxResources.get('industry21'), path: 'industrial/液态渣池.svg' },
			{ name: mxResources.get('industry22'), path: 'industrial/漏斗.svg' },
			{ name: mxResources.get('industry23'), path: 'industrial/烧结机.svg' },
			{ name: mxResources.get('industry24'), path: 'industrial/畜粪池.svg' },
			{ name: mxResources.get('industry25'), path: 'industrial/石灰粉仓.svg' },
			{ name: mxResources.get('industry26'), path: 'industrial/酒槽水.svg' },
			{ name: mxResources.get('industry27'), path: 'industrial/高效汽轮机.svg' },
		]



		const fns = graphPathLib.map(item => {
			return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
				const cell = new mxCell(createUserObject(cellAttribute), new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
				cell.setVertex(true)

				return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
			}));
		})


		this.setGalleryLib(dt, label, graphPathLib)

		this.addPaletteFunctions(dt, label, false, fns);

		this.setCurrentSearchEntryLibrary();
	};
})();