summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/views/browse/_collectionInfoToolbar.gsp
blob: 4c1eb28627c2d5dbe9d4418d3e0e905a720e71ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<div id="collectionInfoToolbar" >

	<div id="collectionInfoToolbarMenu" class="btn-toolbar">
		
		<div id="collectionInfoButtonGroup1" class="btn-group">
			<button id="setCollectionAsRoot" onclick="cibSetCollectionAsRoot()"><img class="icon-hand-left"/><g:message
					code="text.set.as.root" /></button>
					
					
			<g:if  test="${irodsStarredFileOrCollection}">
				<button id="unstarCollection" onclick="cibUnstarCollection()"><img class="icon-star"/><g:message
					code="text.unstar" /></button>
			</g:if>
			<g:else>
				<button id="starCollection" onclick="cibStarCollection()"><img class="icon-star-empty"/><g:message
					code="text.star" /></button>
			</g:else>

		</div>

		<div id="collectionInfoButtonGroup2" class="btn-group">
			<button id="addCollectionToCart" onclick="addToCartViaToolbar()"><img class="icon-shopping-cart"/><g:message
					code="text.add.to.cart" /></button>
			<button id="uploadViaBrowser" onclick="cibUploadViaBrowser()"><img class="icon-upload"/><g:message
					code="text.upload" /></button>
			<button id="bulkUploadViaBrowser" onclick="cibBulkUploadViaBrowser()"><img class="icon-upload"/><g:message
					code="text.bulk.upload" /></button>
			
		</div>
		<div id="collectionInfoButtonGroup3" class="btn-group">
			<button id="newCollection" onclick="cibNewFolder()"><img class="icon-plus-sign"/><g:message
					code="text.new.folder" /></button>
			<button id="renameCollection" onclick="cibRenameCollection()"><img class="icon-pencil"/><g:message
					code="text.rename" /></button>
			<button id="deleteCollection" onclick="cibDeleteCollection()"><img class="icon-trash"/><g:message
					code="text.delete" /></button>
		</div>
</div>


<script type="text/javascript">

	function cibSetCollectionAsRoot() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		setTreeToGivenPath(path);

		
	}

	/**
	* Show the uplaod dialog using the hidden path in the info view
	*/
	function cibUploadViaBrowser() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		showUploadDialogUsingPath(path);

		
	}

	/**
	* Launch iDrop lite for bulk uplaod mode
	*/
	function cibBulkUploadViaBrowser() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		showIdropLiteGivenPath(path, 2);
	}

	/**
	* Create a new folder underneath the current directory
	**/
	function cibNewFolder() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}
		newFolderViaToolbarGivenPath(path);
	}

	/**
	* Delete the collection currently displayed in the info view
	*/
	function cibRenameCollection() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		renameViaToolbarGivenPath(path);
	}

	
	/**
	* call delete using the path in the info panel
	*/
	function cibDeleteCollection() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		deleteViaToolbarGivenPath(path);
	}

	/**
	* favorite, or 'star' the collection currently displayed in the info view
	*/
	function cibStarCollection() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		if (path == null) {
			setErrorMessage("No path was selected, use the tree to select an iRODS collection or file to star"); // FIXME:
			// i18n
			return;
		}

		lcShowBusyIconInDiv("#infoDialogArea");
		var url = "/browse/prepareStarDialog";

		var params = {
			absPath : path
		}

		lcSendValueWithParamsAndPlugHtmlInDiv(url, params, "#infoDialogArea", null);
	}

	/**
	* unfavorite favorite, or 'star' the collection currently displayed in the info view
	*/
	function cibUnstarCollection() {
		var path = $("#infoAbsPath").val();
		if (path == null) {
			showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
			return false;
		}

		if (path == null) {
			setErrorMessage("No path was selected, use the tree to select an iRODS collection or file to unstar"); // FIXME:
			// i18n
			return;
		}

		lcShowBusyIconInDiv("#infoDialogArea");
		var url = "/browse/unstarFile";

		var params = {
			absPath : path
		}

		showBlockingPanel();

		var jqxhr = $.post(context + url, params,
				function(data, status, xhr) {
				}, "html").success(
				function(returnedData, status, xhr) {
					var continueReq = checkForSessionTimeout(returnedData, xhr);
					if (!continueReq) {
						return false;
					}
					setMessage(jQuery.i18n.prop('msg_file_unstarred'));
					updateBrowseDetailsForPathBasedOnCurrentModel(selectedPath);
					closeStarDialog();
					unblockPanel();
				}).error(function(xhr, status, error) {
					setErrorMessage(xhr.responseText);
					closeStarDialog();
					unblockPanel();
				});

	}
	
</script>