- //http://www.html580.com
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLTableSprite', {
- extend: 'Ext.draw.Sprite',
- alias: ['widget.sqltablesprite'],
- bConnections: false,
- startDrag: function(id){
- var me = this, win, sqlTablePanel, xyParentPos, xyChildPos;
- // get a reference to a sqltable
- win = Ext.getCmp(id);
- // get the main sqlTablePanel
- sqlTablePanel = Ext.getCmp('SQLTablePanel');
- // get the main sqlTablePanel position
- xyParentPos = sqlTablePanel.el.getXY();
- // get the size of the previously added sqltable
- xyChildPos = win.el.getXY();
- me.prev = me.surface.transformToViewBox(xyChildPos[0] - xyParentPos[0] + 2, xyChildPos[1] - xyParentPos[1] + 2);
- },
- onDrag: function(relPosMovement){
- var xy, me = this, attr = this.attr, newX, newY;
- // move the sprite
- // calculate new x and y position
- newX = me.prev[0] + relPosMovement[0];
- newY = me.prev[1] + relPosMovement[1];
- // set new x and y position and redraw sprite
- me.setAttributes({
- x: newX,
- y: newY
- }, true);
- }
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLTableModel', {
- extend: 'Ext.data.Model',
- fields: [{
- name: 'id',
- type: 'string'
- }, {
- name: 'tableName',
- type: 'string'
- }, {
- name: 'tableAlias',
- type: 'string'
- }]
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLTableStore', {
- extend: 'Ext.data.Store',
- autoSync: true,
- model: 'Ext.ux.window.visualsqlquerybuilder.SQLTableModel',
- proxy: {
- type: 'memory'
- }
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLJoin', {
- extend: 'Ext.data.Model',
- fields: [{
- name: 'id',
- type: 'string'
- }, {
- name: 'leftTableId',
- type: 'string'
- }, {
- name: 'rightTableId',
- type: 'string'
- }, {
- name: 'leftTableField',
- type: 'string'
- }, {
- name: 'rightTableField',
- type: 'string'
- }, {
- name: 'joinCondition',
- type: 'string'
- }, {
- name: 'joinType',
- type: 'string'
- }],
- createUUID: function(){
- // http://www.ietf.org/rfc/rfc4122.txt
- var s = [];
- var hexDigits = "0123456789abcdef";
- for (var i = 0; i < 36; i++) {
- s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
- }
- s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
- s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
- s[8] = s[13] = s[18] = s[23] = "-";
- var uuid = s.join("");
- return uuid;
- }
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.JoinStore', {
- extend: 'Ext.data.Store',
- autoSync: true,
- model: 'Ext.ux.window.visualsqlquerybuilder.SQLJoin',
- proxy: {
- type: 'memory'
- }
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLFieldsModel', {
- extend: 'Ext.data.Model',
- fields: [{
- name: 'id',
- type: 'string'
- }, {
- name: 'tableName',
- type: 'string'
- }, {
- name: 'tableId',
- type: 'string'
- }, {
- name: 'extCmpId',
- type: 'string'
- }, {
- name: 'tableAlias',
- type: 'string'
- }, {
- name: 'field',
- type: 'string'
- }, {
- name: 'output',
- type: 'boolean'
- }, {
- name: 'expression',
- type: 'string'
- }, {
- name: 'aggregate',
- type: 'string'
- }, {
- name: 'alias',
- type: 'string'
- }, {
- name: 'sortType',
- type: 'string'
- }, {
- name: 'sortOrder',
- type: 'int'
- }, {
- name: 'grouping',
- type: 'boolean'
- }, {
- name: 'criteria',
- type: 'string'
- }]
- });
- Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLFieldsStore', {
- extend: 'Ext.data.Store',
- autoSync: true,
- model: 'Ext.ux.window.visualsqlquerybuilder.SQLFieldsModel',
- proxy: {
- type: 'memory'
- }
- });
转载于:https://blog.51cto.com/html580/1101305