Improve forms participant view
This commit is contained in:
parent
15b935eadc
commit
aa84b625c7
|
@ -618,6 +618,7 @@ define([
|
|||
prefersDriveRedirect: Utils.LocalStore.getDriveRedirectPreference(),
|
||||
isPresent: parsed.hashData && parsed.hashData.present,
|
||||
isEmbed: parsed.hashData && parsed.hashData.embed,
|
||||
canEdit: hashes && hashes.editHash,
|
||||
oldVersionHash: parsed.hashData && parsed.hashData.version < 2, // password
|
||||
isHistoryVersion: parsed.hashData && parsed.hashData.versionHash,
|
||||
notifications: notifs,
|
||||
|
@ -1749,6 +1750,22 @@ define([
|
|||
});
|
||||
});
|
||||
|
||||
sframeChan.on('Q_COPY_VIEW_URL', function (data, cb) {
|
||||
require(['/common/clipboard.js'], function (Clipboard) {
|
||||
var url = window.location.origin +
|
||||
Utils.Hash.hashToHref(hashes.viewHash, 'form');
|
||||
var success = Clipboard.copy(url);
|
||||
cb(success);
|
||||
});
|
||||
});
|
||||
sframeChan.on('EV_OPEN_VIEW_URL', function () {
|
||||
var url = Utils.Hash.hashToHref(hashes.viewHash, 'form');
|
||||
var a = window.open(url);
|
||||
if (!a) {
|
||||
sframeChan.event('EV_POPUP_BLOCKED');
|
||||
}
|
||||
});
|
||||
|
||||
if (cfg.messaging) {
|
||||
sframeChan.on('Q_CHAT_OPENPADCHAT', function (data, cb) {
|
||||
Cryptpad.universal.execCommand({
|
||||
|
|
|
@ -64,7 +64,9 @@ MessengerUI, Messages, Pages) {
|
|||
if (!config.$container) { return; }
|
||||
var $container = config.$container;
|
||||
|
||||
var isEmbed = Bar.isEmbed = config.metadataMgr.getPrivateData().isEmbed;
|
||||
var priv = config.metadataMgr.getPrivateData();
|
||||
var isEmbed = Bar.isEmbed = priv.isEmbed ||
|
||||
(priv.app === 'form' && priv.readOnly && !priv.form_auditorHash);
|
||||
if (isEmbed) {
|
||||
$container.hide();
|
||||
}
|
||||
|
|
|
@ -78,6 +78,26 @@
|
|||
display: flex;
|
||||
}
|
||||
|
||||
.cp-form-view-title {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
div.cp-form-view-logo {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
max-height: 140px;
|
||||
font-size: 50px;
|
||||
display: flex;
|
||||
font-family: "IBM Plex Mono";
|
||||
.tools_unselectable();
|
||||
color: @cp_sidebar-hint;
|
||||
padding: 20px;
|
||||
cursor: pointer;
|
||||
img {
|
||||
max-height: 100%;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
div.cp-form-creator-container {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
define([
|
||||
'jquery',
|
||||
'json.sortify',
|
||||
'/api/config',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/common/sframe-app-framework.js',
|
||||
'/common/toolbar.js',
|
||||
|
@ -42,6 +43,7 @@ define([
|
|||
], function (
|
||||
$,
|
||||
Sortify,
|
||||
ApiConfig,
|
||||
Crypto,
|
||||
Framework,
|
||||
Toolbar,
|
||||
|
@ -2608,7 +2610,24 @@ define([
|
|||
}
|
||||
|
||||
// In view mode, add "Submit" and "reset" buttons
|
||||
// Embed mode is enforced so we add the title at the top and a CryptPad logo
|
||||
// at the bottom
|
||||
var title = framework._.title.title || framework._.title.defaultTitle;
|
||||
$container.prepend(h('h1.cp-form-view-title', title));
|
||||
|
||||
$container.append(makeFormControls(framework, content, Boolean(answers), evOnChange));
|
||||
|
||||
var logo = h('div.cp-form-view-logo', [
|
||||
h('img', {
|
||||
src:'/customize/CryptPad_logo_grey.svg?'+ApiConfig.requireConf.urlArgs,
|
||||
alt:'CryptPad_logo'
|
||||
}),
|
||||
h('span', 'CryptPad')
|
||||
]);
|
||||
$(logo).click(function () {
|
||||
framework._.sfCommon.gotoURL('/drive/');
|
||||
});
|
||||
$container.append(logo);
|
||||
if (!answers) {
|
||||
$container.find('.cp-reset-button').attr('disabled', 'disabled');
|
||||
}
|
||||
|
@ -2672,6 +2691,22 @@ define([
|
|||
}
|
||||
|
||||
var makeFormSettings = function () {
|
||||
Messages.form_preview = "Preview participant page"; // XXX
|
||||
Messages.form_geturl = "Copy participant link"; // XXX
|
||||
var previewBtn = h('button.btn.btn-primary', Messages.form_preview);
|
||||
var participantBtn = h('button.btn.btn-primary', Messages.form_geturl);
|
||||
var preview = h('div.cp-forms-results-participant', [previewBtn, participantBtn]);
|
||||
$(previewBtn).click(function () {
|
||||
sframeChan.event('EV_OPEN_VIEW_URL');
|
||||
});
|
||||
$(participantBtn).click(function () {
|
||||
sframeChan.query('Q_COPY_VIEW_URL', null, function (err, success) {
|
||||
if (success) { return void UI.log(Messages.shareSuccess); }
|
||||
UI.warn(Messages.error);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Private / public status
|
||||
var resultsType = h('div.cp-form-results-type-container');
|
||||
var $results = $(resultsType);
|
||||
|
@ -2873,6 +2908,7 @@ define([
|
|||
//evOnChange.reg(refreshResponse);
|
||||
|
||||
return [
|
||||
preview,
|
||||
endDateContainer,
|
||||
privacyContainer,
|
||||
resultsType,
|
||||
|
|
Loading…
Reference in New Issue