Blame view

js/app/views/RemoteSearchPlugin.js 2.08 KB
16035364   Benjamin Renard   First commit
1
2
3
/**
  * Project      :  AMDA-NG
  * Name         : RemoteSearchPlug.js
b530f31f   Elena.Budnik   remote sites from...
4
5
  * @plugin 	  remoteSearchPlugin
  * @extends 	  Ext.AbstractPlugin         
16035364   Benjamin Renard   First commit
6
7
8
9
10
11
12
13
14
15
16
  */


Ext.define('amdaUI.RemoteSearchPlugin', {
	extend: 'Ext.AbstractPlugin',
	alias: 'plugin.remoteSearchPlugin',
	 	
	moduleId : 'up-win',
 
	win : null,
	
b530f31f   Elena.Budnik   remote sites from...
17
18
19
	constructor: function(config) { 	  
		Ext.apply(this, config);  
		this.callParent(arguments);
16035364   Benjamin Renard   First commit
20
21
22
23
	},
 	
	
	init: function(cmp) {
b530f31f   Elena.Budnik   remote sites from...
24
25
26
27
		this.hostCmp = cmp;   
		this.hostCmp.on({
			open: this.onOpen, 	
			scope: this});
16035364   Benjamin Renard   First commit
28
	},
b530f31f   Elena.Budnik   remote sites from...
29

16035364   Benjamin Renard   First commit
30
	onDestroy : function() {
b530f31f   Elena.Budnik   remote sites from...
31
			this.win = null;
16035364   Benjamin Renard   First commit
32
33
34
	},
			
	onOpen: function(url) {
b530f31f   Elena.Budnik   remote sites from...
35
36
		//TODO just reload tree
		if (this.win) this.win.destroy();
16035364   Benjamin Renard   First commit
37
38
	   
		if (!this.win) {
b530f31f   Elena.Budnik   remote sites from...
39
40
41
42
43
44
45
46
47
48
			this.win = new Ext.Window({			
				id: 'remoteSearch-win',  
				width: 310, 
				height: 500,			 	 
				title: url,
				layout: 'fit',
				constrain: true,
				ghost: false,			 
				items: this.getTree(url),
				getConstrainVector: function(constrainTo){
16035364   Benjamin Renard   First commit
49
					var me = this;
b530f31f   Elena.Budnik   remote sites from...
50
51
52
53
54
55
56
57
58
59
						if (me.constrain || me.constrainHeader) {
							constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
							return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
						}
					}
			});
			this.win.on('destroy', this.onDestroy, this);	 

			this.win.show();
		}
16035364   Benjamin Renard   First commit
60
61
	},
	
b530f31f   Elena.Budnik   remote sites from...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	getTree : function(url) 
	{
		var store = Ext.create('Ext.data.TreeStore', {
			model: 'amdaModel.AmdaNode',		     
			root: {
				text: url,	   
				nodeType : 'url',
				expanded: true
			} ,
			listeners: {
				scope : this,
				beforeload: function(store, operation){
					store.proxy.extraParams = {
						nodeType: 'url',
						baseId: url
					}
				}	     
			}
		});
16035364   Benjamin Renard   First commit
81
	  
b530f31f   Elena.Budnik   remote sites from...
82
83
84
85
86
87
88
89
90
91
92
93
		var tree = Ext.create('Ext.tree.Panel', {
			store: store,
			listeners : {
				scope : this,
				itemdblclick: function(view, record, item, index, event){
					event.stopEvent();
					var form = this.hostCmp.down('form').next().getForm();
					form.getFields().getAt(1).setValue(record.internalId);	// internalId ??			
					this.win.destroy();
				}
			}
		});
16035364   Benjamin Renard   First commit
94
	  
b530f31f   Elena.Budnik   remote sites from...
95
		return tree;	     	  	  
16035364   Benjamin Renard   First commit
96
97
98
	}
		
});