Skip to content
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

Fenêtre modales d'export chargées de maniéré asynchrone #82

Merged
merged 4 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions application/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ a[disabled] {
animation-name: animatetop;
animation-duration: 0.4s;
}

@media (max-width: 768px) {
.export_content {
margin: 0;
width: 100%;
}
}

.export_content .navbar {
border-radius: 0;
height: 50px;
Expand Down
82 changes: 82 additions & 0 deletions application/assets/js/perpage/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
Copyright 2017 Nino Treyssat-Vincent, Parti Pirate

This file is part of Congressus.

Congressus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Congressus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Congressus. If not, see <http://www.gnu.org/licenses/>.
*/
$('.btnTab').click(function(){
tab = $(this).data("tab");
template = $(this).data("template");
if (tab=='rendering'){
textarea = 'false';
$('#html-code').removeClass('btn-active');
$('#html-code').removeClass('hidden-xs');
$('#rendering').addClass('btn-active');
$('#rendering').addClass('hidden-xs');
} else if (tab=='html-code'){
textarea = 'true';
$('#html-code').addClass('btn-active');
$('#html-code').addClass('hidden-xs');
$('#rendering').removeClass('btn-active');
$('#rendering').removeClass('hidden-xs');
} else if (tab=='preview'){
$('#preview').addClass('btn-active');
$('#preview').addClass('hidden-xs');
$('#send_discourse').removeClass('btn-active');
$('#send_discourse').removeClass('hidden-xs');
$('#discourse_post').hide();
$('#export_iframe').show();
} else if (tab=='send_discourse'){
$('#preview').removeClass('btn-active');
$('#preview').removeClass('hidden-xs');
$('#send_discourse').addClass('btn-active');
$('#send_discourse').addClass('hidden-xs');
$('#discourse_post').show();
$('#export_iframe').hide();
}
url = "meeting/do_export.php?template=" + template + "&id=" + meeting_id + "&textarea=" + textarea;
$('#export_iframe').attr("src", url);
$('#newpage').attr("href", url);
});

// closed by <span>X
$('.exportClose').click(function(){
$("#exportModal").empty();
});

// Post
$( "#discourseSubmit" ).click(function( event ) {
event.preventDefault();

discourse_title = $('input[name="discourse_title"]').val();
if (discourse_title.length > 15) {
discourse_category = $('select[name="discourse_category"]').val();
if (discourse_category !== "") {
meetingId = meeting_id;
url = "meeting_api.php?method=do_discoursePost";
var posting = $.post( url, { discourse_title: discourse_title, discourse_category: discourse_category, meetingId: meetingId } );

posting.done(function( data ) {
var content = $(data);
$("#result").empty().append(content);
});
} else {
$("#result").empty().append("<div id='discourse-result' class='alert alert-danger' role='alert'>" + export_category_choose +"</div>");
}
} else {
$("#result").empty().append("<div id='discourse-result' class='alert alert-danger' role='alert'>" + export_discourse_shortTitle +"</div>");
}

});
4 changes: 2 additions & 2 deletions application/assets/js/perpage/meeting_agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ function updateMeeting(meeting) {
$("#meeting-status-panel button.btn-close-meeting").hide();
$("#meeting-status-panel button.btn-delete-meeting").hide();
// $("#meeting-status-panel span.closed-meeting").hide();
$("#btn-export-discourse").hide();
$("#send_discourse").hide();
} else {
$("#btn-export-discourse").show();
$("#send_discourse").show();
}

if (meeting.mee_datetime) {
Expand Down
39 changes: 9 additions & 30 deletions application/assets/js/perpage/meeting_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,28 @@
You should have received a copy of the GNU General Public License
along with Congressus. If not, see <http://www.gnu.org/licenses/>.
*/
function loadExport(format, meeting_id, textarea){
exportModal = $('#export_container_' + format);
$('#iframe_' + format).attr("src", "meeting/do_export.php?template=" + format + "&id=" + meeting_id + "&textarea=" + textarea);
if(format=='html'){$('#newpage_html').attr("href", $('#iframe_' + format).attr("src"));}
exportModal.show();
}
function closeExport(exportModal){
$('#iframe').attr("src", "");
exportModal.hide();
}

$('.btnShowExport').click(function(){
format = $(this).data("format");
if (format=='markdown' || format=='discourse' || format=='html-code'){
template = $(this).data("template");
if (template=='markdown' || template=='discourse'){
textarea = 'true';
} else {
textarea = 'false';
}
if (format=='html'){
$('#rendering').addClass('btn-active');
$('#html-code').removeClass('btn-active');
}
if (format=='html-code'){
format = 'html';
$('#html-code').addClass('btn-active');
$('#rendering').removeClass('btn-active');
}
loadExport(format, meeting_id, textarea);
$.get("export.php", {template: template, id: meeting_id, textarea: textarea}, function(data){
$("#exportModal").empty().append(data);
});
});

// closed by <span>X
$('.exportClose').click(function(){
closeExport(exportModal);
});
// closed by esc
$(document).keyup(function(e) {
$(window).keyup(function(e) {
if (e.keyCode == 27) {
closeExport(exportModal);
$("#exportModal").empty();
}
});
// closed by click outside of modal
$(window).on('click', function(event){
$(document).on('click', function(event){
if(event.target.id.slice(0,16) == "export_container"){
closeExport(exportModal);
$("#exportModal").empty();
}
});
34 changes: 0 additions & 34 deletions application/assets/js/perpage/meeting_export_discourse.js

This file was deleted.

9 changes: 5 additions & 4 deletions application/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
<!-- Form Name -->
<legend><?php echo lang("connect_form_legend"); ?></legend>

<?php
<?php

if (isset($_GET["error"])) {
?><div class="text-danger text-center"><?php
?><div class="text-danger text-center"><?php
echo lang($_GET["error"]);
?></div><?php
?></div><?php
}
?>

Expand Down Expand Up @@ -90,6 +90,7 @@ class="glyphicon glyphicon-ok form-control-feedback otbHidden" aria-hidden="true
<div class="form-group">
<div class="col-md-12 text-center">
<button id="connectButton" name="connectButton" class="btn btn-primary"><?php echo lang("common_connect"); ?></button>
<p class="help-block"><a href="https://gestion.partipirate.org/lostpasswd.php"><?php echo lang("forgotten_link");?></a></p>
</div>
</div>
</fieldset>
Expand All @@ -103,4 +104,4 @@ class="glyphicon glyphicon-ok form-control-feedback otbHidden" aria-hidden="true
</script>
<?php include("footer.php");?>
</body>
</html>
</html>
141 changes: 141 additions & 0 deletions application/export.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php /*
Copyright 2017 Nino Treyssat-Vincent, Parti Pirate

This file is part of Congressus.

Congressus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Congressus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Congressus. If not, see <http://www.gnu.org/licenses/>.
*/
// include_once("header.php");
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

include_once("config/database.php");
include_once("language/language.php");
include_once("config/discourse.structure.php");
require_once("engine/bo/MeetingBo.php");
require_once("engine/utils/SessionUtils.php");
require_once("config/config.php");

$connection = openConnection();
$meetingBo = MeetingBo::newInstance($connection);
$meeting = $meetingBo->getById($_REQUEST["id"], true);
if (!$meeting) {
// Ask for creation
$meeting = array("mee_label" => lang("meeting_eventNew"));
}
else {
$start = new DateTime($meeting["mee_datetime"]);
$end = new DateTime($meeting["mee_datetime"]);
$duration = new DateInterval("PT" . ($meeting["mee_expected_duration"] ? $meeting["mee_expected_duration"] : 60) . "M");
$end = $end->add($duration);

if ($meeting["loc_type"] == "framatalk") {
$framachan = sha1($meeting["mee_id"] . "framatalk" . $meeting["mee_id"]);
}
}

if (isset($_GET["template"]) && isset($_GET["textarea"]) && isset($_GET["id"])) {
if ($_GET["template"]=="discourse"){

}
$url = "meeting/do_export.php?template=" . $_GET["template"] . "&id=" . $_GET["id"] . "&textarea=" . $_GET["textarea"];
} else {
die();
}

?>
<div class="export_container" id="export_container">
<div class="export_content">
<div class="navbar navbar-inverse">
<div class="navbar-header pull-left hidden-xs">
<a class="navbar-brand" href="#">Export <?php echo $_GET["template"] ?></a>
</div>
<div class="navbar-header pull-left"><?php
if ($_GET["template"]=="html"){?>
<a id="rendering" data-template="html" data-tab="rendering" class="btnTab hidden-xs btn btn-default navbar-btn btn-active" href="#"><?php echo lang("export_rendering"); ?></a>
<a id="html-code" data-template="html" data-tab="html-code" class="btnTab btn btn-default navbar-btn" href="#">Code HTML</a>
<?php } elseif ($_GET["template"]=="discourse") {?>
<a id="preview" data-template="discourse" data-tab="preview" class="btnTab hidden-xs btn btn-default navbar-btn btn-active" href="#"><?php echo lang("export_preview"); ?></a>
<a id="send_discourse" data-template="discourse" data-tab="send_discourse" class="btnTab btn btn-default navbar-btn" href="#"><?php echo lang("export_send_discourse"); ?> <span class="glyphicon glyphicon-share"></span></a>
<?php } ?>
<a id="newpage" class="btn btn-default navbar-btn" href="<?php echo $url ?>" target="_blank"><?php echo lang("export_open"); ?></a>
</div>
<div class="navbar-header pull-right">
<a title="<?php echo lang("common_close"); ?>" class="btn btn-default navbar-btn exportClose" href="#"><span class="glyphicon glyphicon-remove"></span></a>
</div>
</div>
<iframe id="export_iframe" src="<?php echo $url; ?>"><?php echo lang("export_iframes"); ?></iframe>

<div id="discourse_post" class="simply-hidden">
<?php $userId = SessionUtils::getUserId($_SESSION);
if (!isset($userId)) {?>
<div class="container">
<div class="jumbotron alert-danger">
<h2><?php echo lang("export_login_ask"); ?></h2>
<p><?php echo lang("export_permission_guests"); ?></p>
<p><a class='btn btn-danger btn-lg' href='connect.php' role='button'><?php echo lang("login_title"); ?></a></p>
</div>
</div>
<?php // die("error : not_enough_right");
} elseif (($userId !== $meeting["mee_president_member_id"]) AND ($userId !== $meeting["mee_secretary_member_id"])) {?>
<div class="container">
<div class="jumbotron alert-danger">
<h2><?php echo lang("export_permission"); ?></h2>
<p><?php echo lang("export_permission_description"); ?></p>
<p><a class='btn btn-danger btn-lg' href='meeting.php?id=<?php echo $meeting["mee_id"]; ?>' role='button'><?php echo lang("common_back"); ?></a></p>
</div>
</div>
<?php // die("error : not_enough_right");
} ?>
<p class="col-md-12"><?php echo lang("export_description"); ?></p>
<form action="meeting_api.php?method=do_discoursePost" method="post" class="form-horizontal" id="export-to-discourse">

<div class="form-group">
<label for="discourse_title" class="col-md-4 control-label"><?php echo lang("meeting_name"); ?> :</label>
<div class="col-md-6">
<input required type="text" class="form-control input-md" id="discourse_title" name="discourse_title" value="[CR] <?php echo $meeting["mee_label"];?> du <?php echo @$start->format(lang("date_format"))?>"/>
</div>
</div>

<div class="form-group" id="loc_channel_form">
<label for="discourse_category" class="col-md-4 control-label"><?php echo lang("export_category"); ?> : </label>
<div class="col-md-6">
<select required class="form-control input-md" id="discourse_category" name="discourse_category">
<option value=""><?php echo lang("export_category_choose"); ?></option>
<?php
foreach ($categories as $categoy) {
echo "<option value='$categoy[id]'>$categoy[name]</option>";
}
?>
</select>
</div>
</div>

<div class="row text-center">
<button id="discourseSubmit" type="submit" class="btn btn-primary"><?php echo lang("common_create"); ?></button>
</div>

</form>
<div id="result"></div>
</div>

</div>
</div>
<script>
var export_discourse_shortTitle = "<?php echo lang("export_discourse_shortTitle"); ?>";
var export_category_choose = "<?php echo lang("export_category_choose"); ?>";
</script>
<script src="assets/js/perpage/export.js"></script>
Loading