瀏覽代碼

HUE-255. Create ability to refresh the current view with additional get parameters(cherry picked from commit c1328cabff213d1e2bbc26c6fccd04da94d2cf86)

Aaron Newton 15 年之前
父節點
當前提交
7bb8f5c446

+ 36 - 0
apps/jframegallery/src/jframegallery/templates/Refresh.with.params.mako

@@ -0,0 +1,36 @@
+{% comment %}
+Licensed to Cloudera, Inc. under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  Cloudera, Inc. licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+	<head>
+		<title>Refresh with params</title>
+	</head>
+	<body>
+		<div class="jframe_padded">
+			<p>clicking the two links below will update the view to have their corresponding get parameters added. This is cumulative, so clicking each one only updates the relevant param (not deleting others)</p>
+			<a class="ccs-refresh_with_params" data-refresh-params="iLike=cookies">I refresh this view with "iLike=cookies"</a><br/>
+			<a class="ccs-refresh_with_params" data-refresh-params="iLike=cake">I refresh this view with "iLike=cake"</a><br/>
+			<a class="ccs-refresh_with_params" data-refresh-params="youLike=cookies">I refresh this view with "youLike=cookies"</a><br/>
+			<a class="ccs-refresh_with_params" data-refresh-params="youLike=cake">I refresh this view with "youLike=cake"</a><br/>
+			<hr/>
+			the current values: <br/>
+			iLike: ${ get_var("iLike", "~")}<br/>
+			youLike: ${ get_var("youLike", "~")}<br/>
+		</div>
+	</body>
+</html>

+ 1 - 0
desktop/core/static/js/Source/CCS/CCS.JBrowser.js

@@ -42,6 +42,7 @@ requires:
  - /CCS.JFrame.NoScroll
  - /CCS.JFrame.PromptAndPost
  - /CCS.JFrame.Refresh
+ - /CCS.JFrame.RefreshWithParams
  - /CCS.JFrame.SubmitLink
  - /CCS.JFrame.Target
 script: CCS.JBrowser.js

+ 37 - 0
desktop/core/static/js/Source/JFrameLinkers/CCS.JFrame.RefreshWithParams.js

@@ -0,0 +1,37 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*
+---
+description: Refreshes the current URL (including any GET parameters) with additional get parameters as specified.
+provides: [CCS.JFrame.RefreshWithParams]
+requires: [/CCS.JFrame]
+script: CCS.JFrame.RefreshWithParams.js
+
+...
+*/
+
+CCS.JFrame.addGlobalLinkers({
+	/*
+		submit the form that the element is in.
+	*/
+	'.ccs-refresh_with_params': function(event, link) {
+		this.load({
+			requestPath: new URI(this.currentPath).setData(String.parseQueryString(link.getData('refresh-params')), true).toString()
+		});
+	}
+
+});

+ 1 - 0
desktop/core/static/js/package.yml

@@ -43,6 +43,7 @@ sources: [
   Source/JFrameLinkers/CCS.JFrame.NoScroll.js,
   Source/JFrameLinkers/CCS.JFrame.PromptAndPost.js,
   Source/JFrameLinkers/CCS.JFrame.Refresh.js,
+  Source/JFrameLinkers/CCS.JFrame.RefreshWithParams.js,
   Source/JFrameLinkers/CCS.JFrame.SubmitLink.js,
   Source/JFrameLinkers/CCS.JFrame.Target.js,
   Source/Native/String.CCS.js,