From 7db41a9183eb7c7d63549ca5fd0bede9cfebc599 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 5 Jul 2018 07:43:03 +0200 Subject: [PATCH] Display basic information about a group when access to it is forbidden. --- assets/css/pages/groups/pages/forbidden.css | 22 +++++ assets/js/common/functionsSchema.js | 7 ++ assets/js/pages/groups/pages/forbidden.js | 94 +++++++++++++++++++++ assets/js/pages/groups/pages/group.js | 2 +- system/config/dev.config.php | 2 + 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 assets/css/pages/groups/pages/forbidden.css create mode 100644 assets/js/pages/groups/pages/forbidden.js diff --git a/assets/css/pages/groups/pages/forbidden.css b/assets/css/pages/groups/pages/forbidden.css new file mode 100644 index 00000000..e08c0832 --- /dev/null +++ b/assets/css/pages/groups/pages/forbidden.css @@ -0,0 +1,22 @@ +/** + * Access forbidden to page groups stylesheet + * + * @author Pierre HUBERT + */ + +.group-forbidden-page-container { + max-width: 300px; + margin: auto; + margin-top: 15px; + text-align: center; +} + +.group-forbidden-page-container .group-logo { + width: 130px; + margin: auto; + display: block; +} + +.group-forbidden-page-container .group-name { + margin-bottom: 15px; +} \ No newline at end of file diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 0c0ddd5f..6a33137e 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1226,6 +1226,13 @@ var ComunicWeb = { //TODO : implement }, + /** + * Access to group forbidden page + */ + forbidden: { + //TODO : implemement + }, + }, /** diff --git a/assets/js/pages/groups/pages/forbidden.js b/assets/js/pages/groups/pages/forbidden.js new file mode 100644 index 00000000..083617ea --- /dev/null +++ b/assets/js/pages/groups/pages/forbidden.js @@ -0,0 +1,94 @@ +/** + * Access to group forbiden page script + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.groups.pages.forbidden = { + + /** + * Open access forbidden page + * + * @param {Number} id The ID of the target group + * @param {HTMLElement} target The target of the page + */ + open: function(id, target){ + + //Create page container + var pageContainer = createElem2({ + appendTo: target, + type: "div", + class: "group-forbidden-page-container" + }); + + //Loading message target + var loadingMessage = ComunicWeb.common.messages.createCalloutElem( + "Loading", + "Please wait while we load a few information...", + "info"); + pageContainer.appendChild(loadingMessage); + + //Get information about the page + ComunicWeb.components.groups.interface.getInfo(id, function(result){ + + //Remove loading message + loadingMessage.remove(); + + //Check for errors + if(result.error){ + pageContainer.appendChild( + ComunicWeb.common.messages.createCalloutElem( + "Error", + "An error occured while retrieve group information!", + "danger" + ) + ); + } + + //Display forbidden page + ComunicWeb.pages.groups.pages.forbidden.display(id, result, pageContainer); + + }); + + }, + + /** + * Display forbidden page + * + * @param {Number} id The ID of the group + * @param {Object} result Information about the group + * @param {HTMLElement} target The target for the page + */ + display: function(id, result, target){ + + //Create a box to contain information about registration + var box = createElem2({ + appendTo: target, + type: "div", + class: "box box-primary" + }); + + //Box body + var boxBody = createElem2({ + appendTo: box, + class: "box-body" + }); + + //Display basical information about the group + //Group logo + createElem2({ + appendTo: boxBody, + type: "img", + src: result.icon_url, + class: "group-logo" + }); + + //Add group title + createElem2({ + appendTo: boxBody, + type: "h2", + innerHTML: result.name, + class: "group-name" + }); + }, +} \ No newline at end of file diff --git a/assets/js/pages/groups/pages/group.js b/assets/js/pages/groups/pages/group.js index 41119f15..7ac94b5a 100644 --- a/assets/js/pages/groups/pages/group.js +++ b/assets/js/pages/groups/pages/group.js @@ -22,7 +22,7 @@ ComunicWeb.pages.groups.pages.group = { //Check the code of the error if(result.error.code == 401){ - need_auth;//TODO : implement + ComunicWeb.pages.groups.pages.forbidden.open(id, target); } else diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 5c59c974..61d92557 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -222,6 +222,7 @@ class Dev { "css/pages/groups/pages/create.css", "css/pages/groups/pages/group.css", "css/pages/groups/pages/settings.css", + "css/pages/groups/pages/forbidden.css", //Groups sections "css/pages/groups/sections/header.css", @@ -427,6 +428,7 @@ class Dev { "js/pages/groups/pages/create.js", "js/pages/groups/pages/group.js", "js/pages/groups/pages/settings.js", + "js/pages/groups/pages/forbidden.js", //Groups sections "js/pages/groups/sections/header.js",