Commit e983868c authored by ramiandrison gova's avatar ramiandrison gova
Browse files

Merge remote-tracking branch 'origin/development' into development

parents 682ea74f e9908bef
......@@ -2,16 +2,25 @@
/* main color = #f2e732 */
/* secondary color = #2c3e50 */
.campaign img {
/*.campaign img {
display: inline-block;
width: 40%;
vertical-align: center;
}
}*/
.campaign .description {
/*.campaign .description {
width: 55%;
display: inline-block;
padding: 0;
}*/
#social-header{
display:none;
}
.social-main-container, #central-container{
min-height:unset;
}
.campaign .fin-progress {
......
......@@ -211,3 +211,6 @@
#filterContainer #input-sec-search .input-global-search {
border-radius: 0px 20px 20px 0px;
}
.btn-filters-select.active{
background-color: red
}
\ No newline at end of file
var filterObj = {
container : "#filterContainer" ,
urlData : baseUrl+"/" + moduleId + "/search/globalautocomplete",
init : function(pInit = null){
mylog.log("PixelHumain filterObj.init",pInit);
//Init variable
var copyFilters = jQuery.extend(true, {}, filterObj);
copyFilters.initVar(pInit);
return copyFilters;
},
initVar : function(pInit){
mylog.log("PixelHumain filterObj.initVar",pInit);
this.container = ( (pInit != null && typeof pInit.container != "undefined") ? pInit.container : "#filterContainer" );
this.urlData = ( (pInit != null && typeof pInit.urlData != "undefined") ? pInit.urlData : "#filterContainer" );
this.initDefaults(pInit);
this.initViews(pInit);
this.initActions(pInit);
},
initDefaults : function(pInit){
mylog.log("PixelHumain filterObj.initDefaults",pInit);
var str = "";
var fObj = this;
if(typeof pInit.defaults != "undefined"){
mylog.log("PixelHumain filterObj.initDefaults defaults");
if(typeof pInit.defaults.fields != "undefined"){
$.each(pInit.defaults.fields,function(k,v){
mylog.log("PixelHumain filterObj.initDefaults fields",k, v);
if(typeof searchObject.filters == "undefined" )
searchObject.filters = {};
if(typeof searchObject.filters[k] == "undefined" )
searchObject.filters[k] = [];
searchObject.filters[k].push(v);
});
}
}
},
initActions : function(pInit){
mylog.log("PixelHumain filterObj.initActions",pInit);
var str = "";
var fObj = this;
if(typeof pInit.filters != "undefined"){
$.each(pInit.filters,function(k,v){
mylog.log("PixelHumain filterObj.initActions each", k,v);
if(typeof v.action != "undefined" && typeof fObj.actions[v.action] != "undefined"){
fObj.actions[v.action](fObj);
}
});
}
},
initViews : function(pInit){
mylog.log("PixelHumain filterObj.initViews",pInit);
var str = '<div class="pull-left text-dark labelFilterTit"><i class="fa fa-filter"></i> <span class="hidden-sm">Filtres</span></div>';
var fObj = this;
if(typeof pInit.filters != "undefined"){
$.each(pInit.filters,function(k,v){
mylog.log("PixelHumain filterObj.initViews each", k,v);
if(typeof v.view != "undefined" && typeof fObj.views[v.view] != "undefined"){
str += fObj.views[v.view](k,v);
}
});
}
str+='<div id="activeFilters" class="col-xs-12 padding-5"></div>';
$(fObj.container).html(str);
fObj.initFilters();
},
initFilters : function(){
mylog.log("PixelHumain filterObj.initFilters");
fObj=this;
getParamsUrls=location.hash.split("?");
if(typeof getParamsUrls[1] != "undefined" ){
var parts = getParamsUrls[1].split("&");
var $_GET = {};
var initScopesResearch={"key":"open","ids":[]};
for (var i = 0; i < parts.length; i++) {
var temp = parts[i].split("=");
$_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
}
if(Object.keys($_GET).length > 0){
$.each($_GET, function(e,v){
v=decodeURI(v);
if(e=="tags"){
tags=v.split(",");
$.each(tags, function(i, tag){
fObj.manage.addActive(fObj,"tags",tag);
});
}
if(e=="cities" || e=="zones"){
if($.inArray(e,["cities","zones","cp"]) > -1) $.each(v.split(","), function(i, j){ initScopesResearch.ids.push(j) });
if(initScopesResearch.key!="" && initScopesResearch.ids.length > 0)
checkMyScopeObject(initScopesResearch, $_GET, function(){
if(typeof myScopes.open != "undefined" && Object.keys(myScopes.open).length > 0){
$.each(myScopes.open, function(i, scope){
if(typeof scope.active != "undefined" && scope.active)
fObj.manage.addActive(fObj, "scope",scope.name,i);
});
}
});
mylog.log(myScopes, "checkherescopes" );
if(typeof myScopes.open != "undefined" && Object.keys(myScopes.open).length > 0){
$.each(myScopes.open, function(i, scope){
if(typeof scope.active != "undefined" && scope.active)
fObj.manage.addActive(fObj, "scope",scope.name,i);
});
}
}
});
}
}
},
search : function(){
searchObject.nbPage=0;
searchObject.count=true;
mylog.log("PixelHumain filterObj.search", searchObject);
startSearch(0/*, null, function(){ if($(".searchEntityContainer").length == 0) $(".projectsProgress").show(); }*/);
},
views : {
tags : function(k,v){
mylog.log("PixelHumain filterObj.views.tags", k,v);
var str = "";
return str;
},
select : function(k,v){
mylog.log("PixelHumain filterObj.views.select", k,v);
var str = "<select>";
str += '<option value="-1" >ALL</option>';
if(typeof v.list != "undefined"){
$.each( v.list ,function(kL,vL){
str +='<option value="'+vL+'" >'+vL+'</option>';
});
}
str += "</select>";
return str;
},
selectList : function(k,v){
mylog.log("PixelHumain filterObj.views.selectList", k,v);
label=(typeof v.name != "undefined") ? v.name: "Ajouter un filtre";
str='<li class="dropdown">'+
'<a href="javascript:;" class="dropdown-toggle menu-button btn-menu" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-label-xs="types" data-toggle="tooltip" data-placement="bottom">'+
label+' <i class="fa fa-angle-down margin-left-5"></i>'+
'</a>'+
'<div class="dropdown-menu arrow_box" style="overflow-y: auto;" aria-labelledby="dropdownTypes">'+
'<div class="list-filters">';
if(typeof v.list != "undefined"){
includeSubList=(typeof v.list=="object" && !Array.isArray(v.list)) ? true : false;
$.each( v.list ,function(kL,vL){
if(includeSubList){
str +='<button class="mainTitle col-xs-12" data-field="'+v.field+'" data-type="'+v.type+'" data-value="'+kL+'" >'+kL+'</button>';
if(Object.keys(vL).length > 0){
$.each(vL, function(i, sub){
str +='<button class="col-xs-12" data-field="'+v.field+'" data-type="'+v.type+'" data-value="'+sub+'" >'+sub+'</button>';
});
}
}else{
str +='<button class="col-xs-12" data-field="'+v.field+'" data-type="'+v.type+'" data-value="'+vL+'" >'+vL+'</button>';
}
});
}
str+='</div></div>'+
'</li>';
return str;
},
scope : function(){
mylog.log("PixelHumain filterObj.views.scope");
return '<div id="costum-scope-search"><div id="input-sec-search">'+
'<div class="input-group shadow-input-header">'+
'<span class="input-group-addon scope-search-trigger">'+
'<i class="fa fa-map-marker fa-fw" aria-hidden="true"></i>'+
'</span>'+
'<input type="text" class="form-control input-global-search" autocomplete="off"'+
' id="searchOnCity" placeholder="Où ?">'+
'</div>'+
'<div class="dropdown-result-global-search col-xs-12 col-sm-5 col-md-5 col-lg-5 no-padding" '+
' style="display: none;">'+
'<div class="content-result">'+
'</div>'+
'</div>'+
'</div></div>';
}
},
actions : {
tags : function(fObj){
mylog.log("PixelHumain filterObj.actions.tags");
$("button[data-type='tags']").off().on("click",function(){
mylog.log("PixelHumain filterObj.actions.tags click");
searchObject.tags.push($(this).data("value"));
fObj.search();
fObj.manage.addActive(fObj,"tags",$(this).data("value"), $(this).data("key"), $(this).data("field"));
});
},
filters : function(fObj){
mylog.log("PixelHumain filterObj.actions.filters");
$("button[data-type='filters']").off().on("click",function(){
mylog.log("PixelHumain filterObj.actions.filters click");
if(typeof $(this).data("field") != "undefined"){
if(typeof searchObject.filters == "undefined" )
searchObject.filters = {};
if(typeof searchObject.filters[$(this).data("field")] == "undefined" )
searchObject.filters[$(this).data("field")] = [];
searchObject.filters[$(this).data("field")].push($(this).data("value"));
fObj.search();
fObj.manage.addActive(fObj, "filters",$(this).data("value"), $(this).data("key"), $(this).data("field"));
}
});
},
scope : function(fObj){
mylog.log("PixelHumain filterObj.actions.scope");
myScopes.open={};
bindSearchCity("#costum-scope-search", function(){
$(".item-globalscope-checker").off().on('click', function(){
mylog.log("PixelHumain filterObj.actions.scope click");
$("#costum-scope-search .input-global-search").val("");
$(".dropdown-result-global-search").hide(700).html("");
myScopes.type="open";
mylog.log("PixelHumain filterObj.actions.scope globalscope-checker", $(this).data("scope-name"), $(this).data("scope-type"));
newScope=scopeObject(myScopes.search[$(this).data("scope-value")]);
$.each(newScope, function(e, v){
if(typeof v.active == "undefined" || !v.active)
delete newScope[e];
else
newKeyScope=e;
});
myScopes.open[newKeyScope]=newScope[newKeyScope];
localStorage.setItem("myScopes",JSON.stringify(myScopes));
fObj.manage.addActive(fObj, "scope",$(this).data("scope-name"),newKeyScope);
fObj.search();
});
});
}
},
manage:{
addActive: function(fObj, type, value, key, field){
mylog.log("PixelHumain filterObj.manage.addActive", type, value, key);
var dataKey = (typeof key != "undefined") ? 'data-key="'+key+'" ' : "" ;
var dataField = (typeof field != "undefined") ? 'data-field="'+field+'" ' : "" ;
str='<div class="filters-activate tooltips" data-position="bottom" data-title="Effacer" '+
dataKey +
dataField +
'data-value="'+value+'" '+
'data-name="'+name+'" '+
'data-type="'+type+'">' +
"<i class='fa fa-times-circle'></i>"+
"<span "+
"class='activeFilters' "+
dataKey +
dataField +
'data-value="'+value+'" '+
'data-scope-name="'+name+'" '+
'data-type="'+type+'">' +
value +
"</span>"+
"</div>";
$(fObj.container+" #activeFilters").append(str);
coInterface.initHtmlPosition();
$(fObj.container+" .filters-activate").off().on("click",function(){
fObj.manage.removeActive(fObj, $(this).data("type"), $(this).data("value"), $(this).data("key"), $(this).data("field"));
$(this).fadeOut(200);
coInterface.initHtmlPosition();
});
},
removeActive : function(fObj, type, value, key, field){
mylog.log("PixelHumain filterObj.manage.removeActive", type, value, key, field);
if(type=="filters"){
mylog.log("PixelHumain filterObj.manage.removeActive filters", searchObject);
if( typeof searchObject.filters != "undefined" && typeof searchObject.filters[field] != "undefined")
searchObject.filters[field].splice(searchObject.filters[field].indexOf(value),1);
}
else if(type=="tags")
searchObject.tags.splice(searchObject.tags.indexOf(value),1);
else if(type=="scope"){
delete myScopes.open[key];
}
fObj.search();
}
}
};
\ No newline at end of file
adminPanel.views.collectifLocaux = function(){
var data={
title : "Collectif locaux",
title : "Porteurs de communs",
types : ["organizations"],
csv : [
{
url : baseUrl+'/costum/pacte/collectifsignedcsv',
name : "Les collectifs actifs avec lien de modification",
defaults : {
indexStep : 0
}
table : {
name: {
name : "Nom",
},
{
url : baseUrl+'/api/organization/get/format/csv/key/siteDuPactePourLaTransition',
name : "Tous les groupes",
defaults : {
indexStep : 0,
scope:{
name : "Ville"
}
},
actions:{
validateSource : true,
updateCollectif : true,
delete : true,
update : true
},
paramsFilter : {
container : "#filterContainer",
defaults : {
types : [ "organizations" ]
},
filters : {
text : true
}
}
],
};
ajaxPost('#content-view-admin', baseUrl+'/'+moduleId+'/admin/directory/', data, function(){},"html");
};
adminPanel.views.communs = function(){
var data={
title : "Les communs co-financés",
types : ["projects"],
table : {
nameCollectif: {
name: {
name : "Nom",
},
scope:{
name : "Ville"
},
statusPacte : {
name : "Statut"
}
//pdf : true,
},
actions:{
validateSource : true,
updateCollectif : true,
delete : true
},
paramsFilter : {
container : "#filterContainer",
defaults : {
types : [ "Group" ]
actions:{
delete : true,
update : true
},
paramsFilter : {
container : "#filterContainer",
defaults : {
types : [ "projects" ]
},
filters : {
text : true,
category : {
view : "selectList",
type : "filters",
field : "category",
name : "Engagement du collectif",
action : "filters",
event : "filters",
list : {
"soutien" : "Soutien pacte",
"actif" : "Collectif actif",
"actifSigned" : "Collectif engagé",
}
},
status : {
view : "selectList",
type : "filters",
field : "source.toBeValidated",
name : "Statuts",
action : "filters",
event : "exists",
list : {
"1" : "En attente de validation"
}
}
text : true
}
}
......@@ -73,52 +61,40 @@ adminPanel.views.collectifLocaux = function(){
ajaxPost('#content-view-admin', baseUrl+'/'+moduleId+'/admin/directory/', data, function(){},"html");
};
adminPanel.views.pledge = function(){
var data={
title : "Contrat",
types : ["poi"],
title : "Promesses de don",
//types : ["crowdfunding"],
table : {
name: {
name : "Nom",
notLink : true
name : "Nom"
},
scope:{
name : "Ville"
amount : {
name : "Montant",
sum : true
},
statusPacte : {
name : "Statut"
type : {
name : "type"
},
validateField :{
field : "type",
value : "donation"
}
//pdf : true,
},
},
actions:{
validateSource : true,
updateContract : true,
delete : true
delete : true,
validatePledge : true
},
paramsFilter : {
container : "#filterContainer",
defaults : {
types : [ "poi" ],
type : "contract",
types : [ "crowdfunding" ],
//type : "pledge"
filters : {
type : "contract"
},
fields : {}
},
filters : {
text : true,
status : {
view : "selectList",
type : "filters",
field : "source.toBeValidated",
name : "Statuts",
action : "filters",
event : "exists",
list : {
"1" : "En attente de validation"
}
type : "pledge"
}
}
}
......@@ -126,21 +102,10 @@ adminPanel.views.pledge = function(){
};
ajaxPost('#content-view-admin', baseUrl+'/'+moduleId+'/admin/directory/', data, function(){},"html");
};
adminPanel.views.exportcontract = function(){
window.open(baseUrl+'/api/poi/get/format/csv/key/siteDuPactePourLaTransition/type/contract/limit/0');
};
adminPanel.views.exportcandidat = function(){
window.open(baseUrl+'/api/person/get/format/csv/key/siteDuPactePourLaTransition/tags/candidat2020/limit/0');
};
adminPanel.views.importcontrat = function(){
ajaxPost('#content-view-admin', baseUrl+'/costum/pacte/importcontrat/', {}, function(){},"html");
};
adminPanel.views.importcollectif = function(){
ajaxPost('#content-view-admin', baseUrl+'/costum/pacte/importcollectif/', {}, function(){},"html");
};
adminDirectory.bindCostum = function(aObj){
mylog.log("validateSourceBtn");
$(".validateSourceBtn").off().on("click", function(){
mylog.log("validatePledgeBtn");
$(".validatePledgeBtn").off().on("click", function(){
$(this).find("i").removeClass("fa-check").addClass("fa-spinner fa-spin");
var $this=$(this);
var params={
......@@ -149,58 +114,32 @@ adminDirectory.bindCostum = function(aObj){
};
ajaxPost(
null,
baseUrl+'/costum/pacte/validategroup',
baseUrl+'/co2/crowdfunding/validatepledge/type/'+params.type+'/id/'+params.id,
params,
function(data){
if ( data && data.result ) {
successToast=($this.data("type")=="organizations") ? "Le collectif est bien validé": "Le contrat est validé";
successMsg=($this.data("type")=="organizations") ? "Groupe validé" : "Contrat validé";
toastr.success(successToast);
$this.remove();
$("#"+$this.data("type")+$this.data("id")+" .statusPacte").html("<span class='badge bg-green-k'><i class='fa fa-check'></i> "+successMsg+"</span>");
} else {
toastr.error("Un problème est survenu lors de la validation");
mylog.log("validatepledge callback",data);
if(data.result==true){
toastr.success(data.msg);
urlCtrl.loadByHash(location.hash);
}
else{
toastr.error(trad.somethingwentwrong);
}
}
);
});
};
adminDirectory.values.nameCollectif = function(e, id, type, aObj){
var str="";
if(typeof e.category != "undefined" && $.inArray(e.category, ["actif", "actifSigned"]) >= 0)
str = '<a href="https://pacte-transition.org/#page.type.organizations.id.'+id+'.edit.'+id+'" target="_blank">'+e.name+'</a>';
else
str = '<span>'+e.name+'</span>';
return str;
};
adminDirectory.values.statusPacte = function(e, id, type, aObj){
var str="";
if(typeof e.source != "undefined" && typeof e.source.toBeValidated != "undefined" && e.source.toBeValidated)
str+="<span class='badge bg-orange'><i class='fa fa-check'></i> En attente de validation</span>";