-
-
Notifications
You must be signed in to change notification settings - Fork 233
Setting for app preview #13779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting for app preview #13779
Changes from all commits
ae8bd19
f850ffe
911ff65
003572e
7c31664
e0f871d
f5a3509
8c9a165
076c4c2
16f249c
5497bcc
d31a03f
3772d57
9dc24fb
14e5d9d
7c783cc
4a1366f
99e162f
658c3f9
d164876
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,15 @@ | ||
| {% load hq_shared_tags %} | ||
|
|
||
| <div id="js-appmanager-preview" class="preview-phone-wrapper"> | ||
| <div class="preview-phone-container"> | ||
| <button type="button" class="btn btn-default js-preview-toggle btn-preview-toggle"> | ||
| <i class="fa fa-close"></i> | ||
| </button> | ||
| <iframe | ||
| class="preview-phone-window" | ||
| frameBorder="0" | ||
| scrolling="no" | ||
| src="{% url 'preview_app' request.domain app.get_id %}"> | ||
| </iframe> | ||
| <button type="button" class="btn btn-default btn-preview-back js-preview-back"> | ||
| <i class="fa fa-arrow-left"></i> | ||
| </button> | ||
| </div> | ||
| <div class="preview-phone-container"> | ||
| <button type="button" class="btn btn-default js-preview-toggle btn-preview-toggle"> | ||
| <i class="fa fa-close"></i> | ||
| </button> | ||
| <iframe class="preview-phone-window" frameBorder="0" scrolling="no" src="{% url 'preview_app' request.domain app.get_id %}"> | ||
| </iframe> | ||
| <div class="hardware-buttons"> | ||
| <button type="button" class="btn btn-default btn-preview-back js-preview-back"> | ||
| <i class="fa fa-arrow-left"></i> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,16 @@ | ||
| {% load hq_shared_tags %} | ||
|
|
||
| <div id="js-appmanager-preview" class="preview-phone-wrapper"> | ||
| <div class="preview-phone-container"> | ||
| <button type="button" class="btn btn-default js-preview-toggle btn-preview-toggle"> | ||
| <i class="fa fa-close"></i> | ||
| </button> | ||
| <iframe | ||
| class="preview-phone-window" | ||
| frameBorder="0" | ||
| scrolling="no" | ||
| src="{% url 'preview_app' request.domain app.get_id %}"> | ||
| </iframe> | ||
| {# todo fix #} | ||
| {# <button type="button" class="btn btn-default btn-preview-back js-preview-back">#} | ||
| {# <i class="fa fa-arrow-left"></i>#} | ||
| {# </button>#} | ||
| </div> | ||
| <div class="preview-phone-container"> | ||
| <button type="button" class="btn btn-default js-preview-toggle btn-preview-toggle"> | ||
| <i class="fa fa-close"></i> | ||
| </button> | ||
| <iframe class="preview-phone-window" frameBorder="0" scrolling="no" src="{% url 'preview_app' request.domain app.get_id %}"> | ||
| </iframe> | ||
| <div class="hardware-buttons"> | ||
| <button type="button" class="btn btn-default btn-preview-back js-preview-back"> | ||
| <i class="fa fa-arrow-left"></i> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,8 @@ | ||
| --- | ||
| +++ | ||
| @@ -11,8 +11,9 @@ | ||
| scrolling="no" | ||
| src="{% url 'preview_app' request.domain app.get_id %}"> | ||
| </iframe> | ||
| - <button type="button" class="btn btn-default btn-preview-back js-preview-back"> | ||
| - <i class="fa fa-arrow-left"></i> | ||
| - </button> | ||
| +{# todo fix #} | ||
| +{# <button type="button" class="btn btn-default btn-preview-back js-preview-back">#} | ||
| +{# <i class="fa fa-arrow-left"></i>#} | ||
| +{# </button>#} | ||
| </div> | ||
| </div> | ||
| @@ -1,4 +1,5 @@ | ||
| {% load hq_shared_tags %} | ||
| + | ||
| <div id="js-appmanager-preview" class="preview-phone-wrapper"> | ||
| <div class="preview-phone-container"> | ||
| <button type="button" class="btn btn-default js-preview-toggle btn-preview-toggle"> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,19 +165,24 @@ FormplayerFrontend.on('startForm', function (data) { | |
|
|
||
| FormplayerFrontend.on("start", function (options) { | ||
| var user = FormplayerFrontend.request('currentUser'), | ||
| savedDisplayOptions, | ||
| appId; | ||
| user.username = options.username; | ||
| user.language = options.language; | ||
| user.apps = options.apps; | ||
| user.domain = options.domain; | ||
| user.formplayer_url = options.formplayer_url; | ||
| user.debuggerEnabled = options.debuggerEnabled; | ||
| user.phoneMode = options.phoneMode; | ||
| user.restoreAs = FormplayerFrontend.request('restoreAsUser', user.domain, user.username); | ||
| user.displayOptions = { | ||
|
|
||
| savedDisplayOptions = _.pick( | ||
| Util.getSavedDisplayOptions(), | ||
| FormplayerFrontend.Constants.ALLOWED_SAVED_OPTIONS | ||
| ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. essentially we'll load the saved display options from localStorage. the key is namespaced by domain and username |
||
| user.displayOptions = _.defaults(savedDisplayOptions, { | ||
| phoneMode: options.phoneMode, | ||
| oneQuestionPerScreen: options.oneQuestionPerScreen, | ||
| }; | ||
| }); | ||
|
|
||
| FormplayerFrontend.request('gridPolyfillPath', options.gridPolyfillPath); | ||
| if (Backbone.history) { | ||
|
|
@@ -275,9 +280,7 @@ FormplayerFrontend.on('clearRestoreAsUser', function() { | |
| }) | ||
| ); | ||
|
|
||
| appId = FormplayerFrontend.request('getCurrentAppId'); | ||
|
|
||
| FormplayerFrontend.trigger('navigateHome', appId); | ||
| FormplayerFrontend.trigger('navigateHome'); | ||
| }); | ||
|
|
||
| FormplayerFrontend.on("sync", function () { | ||
|
|
@@ -399,16 +402,18 @@ FormplayerFrontend.on('refreshApplication', function(appId) { | |
| tfLoadingComplete(true); | ||
| }).done(function() { | ||
| tfLoadingComplete(); | ||
| FormplayerFrontend.trigger('navigateHome', appId); | ||
| FormplayerFrontend.trigger('navigateHome'); | ||
| }); | ||
| }); | ||
|
|
||
| FormplayerFrontend.on('navigateHome', function(appId) { | ||
| FormplayerFrontend.on('navigateHome', function() { | ||
| var urlObject = Util.currentUrlToObject(), | ||
| appId, | ||
| currentUser = FormplayerFrontend.request('currentUser'); | ||
| urlObject.clearExceptApp(); | ||
| FormplayerFrontend.regions.breadcrumb.empty(); | ||
| if (currentUser.phoneMode) { | ||
| if (currentUser.displayOptions.phoneMode) { | ||
| appId = FormplayerFrontend.request('getCurrentAppId'); | ||
| FormplayerFrontend.navigate("/single_app/" + appId, { trigger: true }); | ||
| } else { | ||
| FormplayerFrontend.navigate("/apps", { trigger: true }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /*global FormplayerFrontend, Util */ | ||
|
|
||
| FormplayerFrontend.module("SessionNavigate.AppList", function (AppList, FormplayerFrontend, Backbone, Marionette) { | ||
| AppList.SettingsView = Marionette.ItemView.extend({ | ||
| ui: { | ||
| oneQuestionPerScreen: '.js-one-question-per-screen', | ||
| done: '.js-done', | ||
| }, | ||
| events: { | ||
| 'switchChange.bootstrapSwitch @ui.oneQuestionPerScreen': 'onChangeOneQuestionPerScreen', | ||
| 'click @ui.done': 'onClickDone', | ||
| }, | ||
| template: '#settings-template', | ||
| initialize: function() { | ||
| this.currentUser = FormplayerFrontend.request('currentUser'); | ||
| }, | ||
| onRender: function() { | ||
| this.ui.oneQuestionPerScreen.bootstrapSwitch( | ||
| 'state', | ||
| this.currentUser.displayOptions.oneQuestionPerScreen | ||
| ); | ||
| }, | ||
| onChangeOneQuestionPerScreen: function(e, switchValue) { | ||
| this.currentUser.displayOptions.oneQuestionPerScreen = switchValue; | ||
| Util.saveDisplayOptions(this.currentUser.displayOptions); | ||
| }, | ||
| onClickDone: function() { | ||
| FormplayerFrontend.trigger('navigateHome'); | ||
| }, | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /*global FormplayerFrontend */ | ||
|
|
||
| FormplayerFrontend.Constants = { | ||
| ALLOWED_SAVED_OPTIONS: ['oneQuestionPerScreen'], | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,8 @@ FormplayerFrontend.module("HQ.Events", function(Events, FormplayerFrontend) { | |
| // For Chrome, the origin property is in the event.originalEvent object | ||
| var origin = event.origin || event.originalEvent.origin, | ||
| data = event.data, | ||
| returnValue = null, | ||
| success = true; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was unfortunate, but it's impossible to use postMessage with callbacks since it only accepts serializable data. the only other option is to use |
||
|
|
||
| _.defaults(data, { | ||
| success: function() {}, | ||
| error: function() {}, | ||
| complete: function() {}, | ||
| }); | ||
| if (!origin.endsWith(this.allowedHost)) { | ||
| throw new Error('Disallowed origin ' + origin); | ||
| } | ||
|
|
@@ -35,20 +29,10 @@ FormplayerFrontend.module("HQ.Events", function(Events, FormplayerFrontend) { | |
| throw new Error('Invalid action ' + data.action); | ||
| } | ||
|
|
||
| try { | ||
| switch (data.action) { | ||
| case Events.Actions.BACK: | ||
| FormplayerFrontend.trigger('navigation:back'); | ||
| break; | ||
| } | ||
| } catch (e) { | ||
| success = false; | ||
| data.error(event, data, returnValue); | ||
| } finally { | ||
| data.complete(event, data, returnValue); | ||
| } | ||
| if (success) { | ||
| data.success(event, data, returnValue); | ||
| switch (data.action) { | ||
| case Events.Actions.BACK: | ||
| FormplayerFrontend.trigger('navigation:back'); | ||
| break; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes a minor issue in this PR: #13774 (comment)