Commit 93b3c340 authored by Raph El's avatar Raph El

Merge branch 'development' of https://gitlab.adullact.net/pixelhumain/co2 into development

parents 827ed744 0be4952f
......@@ -1798,6 +1798,8 @@ function resetSearchObject(){
searchObject.initType="",
searchObject.types=[],
searchObject.countType=[];
searchObject.text="";
searchObject.tags=[];
}
......
......@@ -2941,10 +2941,10 @@ var directory = {
},
endOfResult : function(noResult){
str="";
//Event scroll and all searching
$("#btnShowMoreResult").remove();
scrollEnd=true;
if(!notNull(directory.custom)){
//Event scroll and all searching
$("#btnShowMoreResult").remove();
scrollEnd=true;
//msg specific for end search
match= (searchObject.text != "") ? "match" : "";
msg= (notNull(noResult) && noResult) ? trad["noresult"+match] : trad["nomoreresult"+match];
......@@ -2969,6 +2969,13 @@ var directory = {
str = '<div class="pull-left col-md-12 text-left" id="footerDropdown" style="width:100%;">';
str += "<h5 style='margin-bottom:10px; margin-left:15px;border-left: 2px solid lightgray;' class='text-dark padding-20'>"+msg+"<br/>"+contributeMsg+"</h5><br/>";
str += "</div>";
}else{
$("#btnShowMoreResult").remove();
match= (searchObject.text != "") ? "match" : "";
msg= (notNull(noResult) && noResult) ? trad["noresult"+match] : trad["nomoreresult"+match];
str = '<div class="pull-left col-xs-12 col-sm-8 col-sm-offset-2 col-md-offset-3 col-md-6 text-center shadow2" id="footerDropdown" style="border-radius: 50px;">';
str += "<h5 class='letter-blue padding-10'><i class='fa fa-ban'></i> "+msg+"</h5>";
str += "</div>";
}
return str;
},
......
......@@ -78,6 +78,7 @@ class CommunecterController extends Controller
"accueil" => array("href" => "/ph/co2/accueil"),
"directory" => array("href" => "/ph/co2/admin/directory"),
"reference" => array("href" => "/ph/co2/admin/reference"),
"setsource" => array("href" => "/ph/co2/admin/setsource"),
"switchto" => array("href" => "/ph/co2/admin/switchto"),
"delete" => array("href" => "/ph/co2/admin/delete"),
"activateuser" => array("href" => "/ph/co2/admin/activateuser"),
......
......@@ -317,7 +317,7 @@
"#admin": {
"inMenu" : false,
"useHeader" : false,
"useHeader" : true,
"useFilter" : false,
"open" : false,
"subdomain" : "admin",
......
......@@ -18,6 +18,7 @@ class AdminController extends CommunecterController {
return array(
'directory' => 'citizenToolKit.controllers.admin.DirectoryAction',
'reference' => 'citizenToolKit.controllers.admin.ReferenceAction',
'setsource' => 'citizenToolKit.controllers.admin.SetSourceAction',
'circuits' => 'citizenToolKit.controllers.admin.CircuitsAction',
'mailerrordashboard' => 'citizenToolKit.controllers.admin.MailErrorDashboardAction',
'switchto' => 'citizenToolKit.controllers.admin.SwitchtoAction',
......
......@@ -227,7 +227,7 @@ function initViewTable(data){
bindAdminBtnEvents();
//resetDirectoryTable() ;
}
function refreshCountBadge(count){
function refreshCountBadgeAdmin(count){
$.each(count, function(e,v){
$("#count"+e).text(v);
});
......@@ -251,7 +251,7 @@ function startAdminSearch(initPage){
initViewTable(data.results);
bindAdminBtnEvents();
if(typeof data.results.count !="undefined")
refreshCountBadge(data.results.count);
refreshCountBadgeAdmin(data.results.count);
console.log(data.results);
if(initPage)
initPageTable(data.results.count[searchAdmin.type]);
......
......@@ -433,8 +433,8 @@
}
function loadDirectory(){
initDashboard();
initType=["citoyens"];
data={initType:initType};
searchAdminType=["citoyens"];
data={initType:searchAdminType};
var url = "admin/directory";
$("#goBackToHome").show(700);
//showLoader('.content-view-dashboard');
......@@ -442,10 +442,10 @@
}
function loadReference(){
initDashboard();
initType=(typeof paramsAdmin != "undefined"
searchAdminType=(typeof paramsAdmin != "undefined"
&& typeof paramsAdmin["reference"] != "undefined"
&& typeof paramsAdmin["reference"]["initType"] != "undefined") ? paramsAdmin["reference"]["initType"]: ["organizations", "events", "projects"];
data={initType:initType};
data={initType:searchAdminType};
var url = "admin/reference";
$("#goBackToHome").show(700);
//showLoader('.content-view-dashboard');
......
......@@ -34,14 +34,14 @@ $layoutPath = 'webroot.themes.'.Yii::app()->theme->name.'.views.layouts.';
<a href="javascript:;" class="sourceFilter" style="cursor:pointer;">
<i class="fa fa-at fa-2x"></i>
<?php echo Yii::t("admin", "source"); ?>
<span class="badge"><?php echo (@$countMenu && @$countMenu["source"]) ? $countMenu["source"]: 0 ; ?></span>
<span id="count-source" class="badge"><?php echo (@$countMenu && @$countMenu["source"]) ? $countMenu["source"]: 0 ; ?></span>
</a>
</li>
<li class="col-xs-12 list-group-item">
<a href="javascript:;" class="referenceFilter" style="cursor:pointer;">
<i class="fa fa-link fa-2x"></i>
<?php echo Yii::t("admin", "Reference"); ?>
<span class="badge"><?php echo (@$countMenu && @$countMenu["reference"]) ? $$countMenu["reference"]: 0 ; ?></span>
<span id="count-reference" class="badge"><?php echo (@$countMenu && @$countMenu["reference"]) ? $countMenu["reference"]: 0 ; ?></span>
</a>
</li>
<li class="col-xs-12 list-group-item">
......@@ -204,7 +204,7 @@ function initViewTable(data){
bindAdminBtnEvents();
//resetDirectoryTable() ;
}
function refreshCountBadge(count){
function refreshCountBadgeAdmin(count){
$.each(count, function(e,v){
$("#count"+e).text(v);
});
......@@ -222,7 +222,7 @@ function startAdminSearch(initPage){
initViewTable(data.results);
bindAdminBtnEvents();
if(typeof data.results.count !="undefined")
refreshCountBadge(data.results.count);
refreshCountBadgeAdmin(data.results.count);
console.log(data.results);
if(initPage)
initPageTable(data.results.count[searchAdmin.type]);
......@@ -335,12 +335,12 @@ function buildDirectoryLine( e, collection, type, icon/* tags, scopes*/ ){
* ACTIONS
***************************************** */
if(searchAdmin.mode=="source"){
action='<li><a href="javascript:;" data-id="'+id+'" data-type="'+type+'" class="margin-right-5 removeFromDataSource btn bg-red"><i class="fa fa-ban text-red"></i> Remove from source</a> </li>';
action='<button data-id="'+id+'" data-type="'+type+'" data-action="remove" data-setkey="source" class="margin-right-5 setSourceAdmin btn bg-red text-white"><i class="fa fa-ban"></i> Remove from source</button>';
}else if (searchAdmin.mode=="reference"){
action='<li><a href="javascript:;" data-id="'+id+'" data-type="'+type+'" class="margin-right-5 removeFromDataReference btn bg-red"><i class="fa fa-ban text-red"></i> Remove from reference</a> </li>';
action='<button data-id="'+id+'" data-type="'+type+'" data-action="remove" data-setkey="reference" class="margin-right-5 setSourceAdmin btn bg-red text-white"><i class="fa fa-ban"></i> Remove from reference</button> ';
}
else if (searchAdmin.mode=="open"){
action='<li><a href="javascript:;" data-id="'+id+'" data-type="'+type+'" class="margin-right-5 addAsReference btn bg-green"><i class="fa fa-plus text-red"></i> Add as reference</a> </li>';
action='<button data-id="'+id+'" data-type="'+type+'" data-action="add" data-setkey="reference" class="margin-right-5 setSourceAdmin btn bg-green text-white"><i class="fa fa-plus"></i> Add as reference</button>';
}
strHTML += '<td class="center">';
strHTML += '<div class="btn-group">'+action
......@@ -441,268 +441,51 @@ function applyScopeFilter(str)
}
function bindAdminBtnEvents(){
mylog.log("bindAdminBtnEvents");
<?php
/* **************************************
* ADMIN STUFF
***************************************** */
if( Yii::app()->session["userIsAdmin"] ) { ?>
$(".activatedUserBtn").off().on("click",function ()
{
mylog.log("validateThisBtn click");
$(this).empty().html('<i class="fa fa-spinner fa-spin"></i>');
var btnClick = $(this);
var id = $(this).data("id");
var type = $(this).data("type");
var urlToSend = baseUrl+"/"+moduleId+"/admin/activateuser/user/"+id;
bootbox.confirm("confirm please !!",
function(result)
{
if (!result) {
btnClick.empty().html('<i class="fa fa-thumbs-down"></i>');
return;
}
$.ajax({
type: "POST",
url: urlToSend,
dataType : "json"
})
.done(function (data)
{
if ( data && data.result ) {
toastr.info("Activated User!!");
btnClick.parents().eq(2).find(".status .tobeactivated").remove();
btnClick.empty().html('<i class="fa fa-thumbs-up"></i>');
} else {
toastr.info("something went wrong!! please try again.");
}
});
});
});
$(".addBetaTesterBtn").off().on("click",function () {
var btnClick = $(this);
bootbox.confirm("confirm please !!", function(result) {
if (result) {
changeRole(btnClick, "addBetaTester");
}
});
});
$(".revokeBetaTesterBtn").off().on("click",function () {
var btnClick = $(this);
bootbox.confirm("confirm please !!", function(result) {
mylog.log("bindReferenceBtnEvents");
$(".setSourceAdmin").off().on("click", function(){
var btnClick=$(this);
if(btnClick.data("setkey")=="source" && btnClick.data("action")=="remove"){
bootbox.confirm("BE carefull, remove a source from an element is not revokable !!<br/>Are you sure to continue ?", function(result) {
if (result) {
changeRole(btnClick, "revokeBetaTester")
setSourceAdmin(btnClick);
}
});
});
$(".addSuperAdminBtn").off().on("click",function () {
var btnClick = $(this);
bootbox.confirm("confirm please !!", function(result) {
if (result) {
changeRole(btnClick, "addSuperAdmin");
}
});
});
$(".revokeSuperAdminBtn").off().on("click",function () {
var btnClick = $(this);
bootbox.confirm("confirm please !!", function(result) {
if (result) {
changeRole(btnClick, "revokeSuperAdmin")
}
});
});
}else
setSourceAdmin(btnClick);
});
$(".switch2UserThisBtn").off().on("click",function ()
{
mylog.log("A FAIRE : switch2UserThisBtn click");
//$(this).empty().html('<i class="fa fa-spinner fa-spin"></i>');
var btnClick = $(this);
var id = $(this).data("id");
var urlToSend = baseUrl+"/"+moduleId+"/admin/switchto/uid/"+id;
bootbox.confirm("confirm please !!",
function(result)
{
if (!result) {
btnClick.empty().html('<i class="fa fa-thumbs-down"></i>');
return;
} else {
$.ajax({
type: "POST",
url: urlToSend,
dataType : "json"
})
.done(function (data)
{
if ( data && data.result ) {
toastr.info("Switched user!!");
location.hash='#page.type.citoyens.id.'+data.id;
window.location.reload();
//window.location.href = baseUrl+"/"+moduleId;
} else {
toastr.error("something went wrong!! please try again.");
}
});
}
});
});
$(".deleteThisBtn").off().on("click",function ()
{
mylog.log("deleteThisBtn click");
var id = $(this).data("id");
var type = $(this).data("type");
var url = baseUrl+"/"+moduleId+"/element/delete/id/"+id+"/type/"+type;
bootbox.confirm("confirm please !!",
function(result)
{
if (!result) {
btnClick.empty().html('<i class="fa fa-thumbs-down"></i>');
return;
} else {
mylog.log("deleteElement", url);
var param = new Object;
// param.reason = $("#reason").val();
$.ajax({
type: "POST",
url: url,
data: param,
dataType: "json",
success: function(data){
if(data.result){
toastr.success(data.msg);
console.log("Retour de delete : "+data.status);
urlCtrl.loadByHash(location.hash);
}else{
toastr.error(data.msg);
}
},
error: function(data){
toastr.error("Something went really bad ! Please contact the administrator.");
}
});
}
});
// var param = new Object;
// param.reason = $("#reason").val();
// $.ajax({
// type: "POST",
// url: url,
// data: param,
// dataType: "json",
// success: function(data){
// if(data.result){
// toastr.success(data.msg);
// console.log("Retour de delete : "+data.status);
// if (data.status == "deleted")
// urlCtrl.loadByHash("#search");
// else
// urlCtrl.loadByHash("#page.type."+type+".id."+id);
// }else{
// toastr.error(data.msg);
// }
// },
// error: function(data){
// toastr.error("Something went really bad ! Please contact the administrator.");
// }
// });
/*$(this).empty().html('<i class="fa fa-spinner fa-spin"></i>');
var btnClick = $(this);
var id = $(this).data("id");
var type = $(this).data("type");
var urlToSend = baseUrl+"/"+moduleId+"/admin/delete/type/"+type+"/id/"+id;
bootbox.confirm("confirm please !!",
function(result)
{
if (!result) {
btnClick.empty().html('<i class="fa fa-thumbs-down"></i>');
return;
} else {
$.ajax({
type: "POST",
url: urlToSend,
dataType : "json"
})
.done(function (data) {
if ( data && data.result ) {
toastr.info("User has been deleted");
$("#"+type+id).remove();
//window.location.href = "";
} else {
toastr.error("something went wrong!! please try again.");
}
});
}
});*/
});
<?php } ?>
$(".banUserBtn").off().on("click",function (){
mylog.log("banThisBtn click");
var btnClick = $(this);
bootbox.confirm("confirm please !!", function(result) {
if (result) {
changeRole(btnClick, "addBannedUser");
}
});
});
$(".unbanUserBtn").off().on("click",function (){
mylog.log("banThisBtn click");
var btnClick = $(this);
bootbox.confirm("confirm to accept this user again !!", function(result) {
if (result) {
changeRole(btnClick, "revokeBannedUser");
}
});
});
}
function changeRole(button, action) {
mylog.log(button," click");
//$(this).empty().html('<i class="fa fa-spinner fa-spin"></i>');
var params ={
type:button.data("type"),
id:button.data("id"),
action:action
}
var urlToSend = baseUrl+"/"+moduleId+"/element/updatestatus";
var res = false;
function setSourceAdmin(btnClick){
var action=btnClick.data("action");
var setKey=btnClick.data("setkey");
var params={
id:btnClick.data("id"),
type:btnClick.data("type")
};
if(typeof custom != "undefined" && notNull(custom) && custom.slug){
params.origin="custom";
params.sourceKey=custom.slug;
}
$.ajax({
type: "POST",
url: urlToSend,
data: params,
dataType : "json"
url: baseUrl+"/"+moduleId+"/admin/setsource/action/"+action+"/set/"+setKey,
data : params
})
.done(function (data) {
.done(function (data)
{
if ( data && data.result ) {
toastr.success("Change has been done !!");
changeButtonName(button, action);
bindAdminBtnEvents();
toastr.success(data.msg);
$("#"+params.type+params.id).fadeOut();
countB=parseInt($("#count-"+setKey).text());
if(action=="remove")
countB--;
else
countB++;
$("#count-"+setKey).text(countB);
//window.location.href = baseUrl+"/"+moduleId;
} else {
toastr.error("Something went wrong!! please try again. " + data.msg);
toastr.error("something went wrong!! please try again.");
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment