diff --git a/Server/app/resources/trade_unions/TradeUnionsController.jl b/Server/app/resources/trade_unions/TradeUnionsController.jl
new file mode 100644
index 0000000..068b489
--- /dev/null
+++ b/Server/app/resources/trade_unions/TradeUnionsController.jl
@@ -0,0 +1,279 @@
+module TradeUnionsController
+
+using Genie, Genie.Renderer, Genie.Renderer.Html, Genie.Requests, GenieAuthentication, DataFrames
+using JSON3
+using SearchLight,SearchLightPostgreSQL, LibPQ, JSON3
+using Server.DatabaseSupport, Server.TemplateEditor, Server.Users
+import Server.DatabaseSupport: select_from_table, insert_into_table, delete_from_table, exist_in_table
+
+controller = "trade_unions"
+dict_layouts = Dict(
+ :trade_unions => generate_layout_html("main",controller,"trade_unions",libraries=["Leaflet"]),
+ :trade_unions_add => generate_layout_html("main",controller,"trade_unions_add",libraries=["Leaflet"]),
+)
+
+#---Page info-----------------------------------------------------
+
+const trade_unions_info = Dict(
+ "en" => Dict(
+ :title => "LibSoc - Trade Unions",
+ :description => ""
+ ),
+ "ru" => Dict(
+ :title => "LibSoc - Профсоюзы",
+ :description => ""
+ )
+)
+
+function get_locale()
+ data = payload()
+ if :locale in keys(data)
+ return data[:locale]
+ else
+ return "en"
+ end
+end
+
+#---Helpers-----------------------------------------------------------
+
+
+function table_to_json(name,df)
+ ar = []
+ for df_row in eachrow(df)
+ dict = Dict()
+ for id in names(df_row)
+ dict[id] = df_row[id]
+ end
+ push!(ar,dict)
+ end
+ open("public/assets/"*name*".json", "w") do io
+ JSON3.write(io, ar)
+ end
+end
+
+function compile(name)
+ df = select_from_table([name => ["*"]])
+ table_to_json(name,df)
+end
+
+function move_requests(name)
+ df_requests = select_from_table(["$(name)_requests" => ["*"]], where_data=["verified" => true, "added" => false])
+ df = select_from_table([name => ["*"]])
+ latitudes = df.latitude
+ longitudes = df.longitude
+ for df_row in eachrow(df_requests)
+ ind_id_given = ismissing(df_row.id_given) ? nothing : findfirst(df_row.id_given.==df.id)
+ if (!isnothing(ind_id_given))
+ id = df[ind_id_given,:id]
+ row_found = df[ind_id_given,Not(:id)]
+ dict = Dict(zip(names(row_found),values(row_found)))
+ dict["members"] += 1
+ update_table(name,dict, where_data=["id" => id])
+ else
+ id = df_row.id
+ dict_update = Dict("added" => true)
+ update_table("$(name)_requests",dict_update, where_data=["id" => id])
+
+ df_row_to_add = df_row[Not(:id_given)]
+ df_row_to_add = df_row_to_add[Not(:verified)]
+ df_row_to_add = df_row_to_add[Not(:added)]
+ df_row_to_add = df_row_to_add[Not(:id)]
+ dict = Dict(zip(names(df_row_to_add),values(df_row_to_add)))
+ dict["members"] = 1
+ insert_into_table(name,dict)
+ end
+ end
+end
+
+#---Functions---------------------------------------------------------
+
+current_user() = findone(Users.User, id = get_authentication())
+
+function trade_unions()
+ locale = get_locale()
+ html(:trade_unions,:trade_unions, layout = dict_layouts[:trade_unions], context = @__MODULE__,
+ title = trade_unions_info[locale][:title],
+ description = trade_unions_info[locale][:description]
+ )
+end
+
+function trade_unions_add()
+ locale = get_locale()
+ html(:trade_unions,:trade_unions_add, layout = dict_layouts[:trade_unions_add], context = @__MODULE__,
+ title = trade_unions_info[locale][:title],
+ description = trade_unions_info[locale][:description]
+ )
+end
+
+function trade_unions_add_post()
+ data = copy(jsonpayload())
+ mode = data["mode"]
+ delete!(data,"mode")
+ user = current_user()
+ user_id = user.id
+ if mode==0 # Create
+ if user.verified
+ existing_user_group_data = select_from_table(["users_trade_unions" => ["*"]], where_data=["user_id" => user_id])
+ has_group = !isempty(existing_user_group_data)
+ delete!(data,"group_id")
+ group_id = insert_into_table("trade_unions",data, "RETURNING id")[1,1]
+ if has_group
+ user_trade_unions_id = existing_user_group_data[1,"id"]
+ prev_group_id = existing_user_group_data[1,"group_id"]
+ update_table("users_trade_unions",Dict("group_id" => group_id), where_data=["id" => user_trade_unions_id])
+ members = select_from_table(["trade_unions" => ["members"]], where_data=["id" => prev_group_id])[1,1]
+ if (members==1)
+ delete_from_table("trade_unions",["id" => prev_group_id])
+ else
+ update_table("trade_unions",Dict("members" => members - 1), where_data=["id" => id])
+ end
+ else
+ dict_users_trade_unions = Dict("user_id" => user.id, "group_id" => group_id)
+ insert_into_table("users_trade_unions",dict_users_trade_unions)
+ end
+ compile("trade_unions")
+ else
+ data["status"] = 0
+ data["user_id"] = user_id
+ insert_into_table("trade_unions_requests",data)
+ end
+ elseif mode==1 # Join
+ data["user_id"] = user_id
+ if exist_in_table("users_trade_unions",["group_id" => data["group_id"]])
+ if exist_in_table("trade_unions_requests",["user_id" => user_id])
+ delete_from_table("trade_unions_requests",["user_id" => user_id])
+ end
+ data["status"] = 0
+ insert_into_table("trade_unions_requests",data)
+ else
+ group_id = data["group_id"]
+ members = select_from_table("trade_unions" => ["members"], where_data = ["id" => group_id])[1,1]
+ dict = Dict("members" => members + 1)
+ update_table("trade_unions",dict, where_data=["id" => group_id])
+ dict_users_trade_unions = Dict("user_id" => user_id, "group_id" => group_id)
+ insert_into_table("users_trade_unions",dict_users_trade_unions)
+ end
+
+ elseif mode==2 # Move
+ existing_user_group_data = select_from_table(["users_trade_unions" => ["*"]], where_data=["user_id" => user_id])
+ group_id = existing_user_group_data[1,"group_id"]
+ delete!(data,"group_id")
+ delete!(data,"members")
+ delete!(data,"contact")
+ update_table("trade_unions",data, where_data=["id" => group_id])
+ compile("trade_unions")
+ elseif mode==3 # Leave
+ existing_user_group_data = select_from_table(["users_trade_unions" => ["*"]], where_data=["user_id" => user_id])
+ if size(existing_user_group_data,1)==0
+ if exist_in_table("trade_unions_requests",["user_id" => user_id])
+ delete_from_table("trade_unions_requests",["user_id" => user_id])
+ end
+ else
+ delete_from_table("users_trade_unions",["user_id" => user_id])
+ end
+ end
+ return nothing
+end
+
+function get_user_trade_unions()
+ local data_dicts
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ data_dicts = []
+ if isnothing(group_id)
+ local data
+ data = select_from_table("trade_unions_requests" => ["*"], where_data = ["user_id" => user_id,"status" => 0])
+ if size(data,1)==0
+ data = select_from_table("trade_unions_requests" => ["*"], where_data = ["user_id" => user_id,"status" => 2])
+ if size(data,1)!=0
+ data = data[[end],:]
+ end
+ end
+ for row in eachrow(data)
+ dict = Dict(zip(names(row),values(row)))
+ if (!ismissing(row["group_id"]))
+ extra_data = select_from_table("trade_unions" => ["*"], where_data = ["id" => row["group_id"]])
+ merge!(dict, Dict(zip(names(extra_data[1,:]),values(extra_data[1,:]))))
+ end
+ push!(data_dicts, dict)
+ end
+ else
+ group_data = select_from_table("trade_unions" => ["*"], where_data = ["id" => group_id])
+ ns = names(group_data)
+ data_dicts = map(x -> Dict(zip(ns,values(x))),eachrow(group_data))
+ end
+ return JSON3.write(data_dicts)
+end
+
+function get_group_requests()
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ data_dicts = []
+ if !isnothing(group_id)
+ user_ids = select_from_table("trade_unions_requests" => ["user_id"], where_data = ["group_id" => group_id, "status" => 0])[:,1]
+ for user2_id in user_ids
+ email = select_from_table("users" => ["email"], where_data = ["id" => user2_id])[1,1]
+ push!(data_dicts,Dict("email" => email, "user_id" => user2_id))
+ end
+ end
+ return JSON3.write(data_dicts)
+end
+
+function approve_request()
+ data = copy(jsonpayload())
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ members = select_from_table("trade_unions" => ["members"], where_data = ["id" => group_id])[1,1]
+ dict = Dict("members" => members + 1)
+ update_table("trade_unions",dict, where_data=["id" => group_id])
+ update_table("trade_unions_requests",Dict("status" => 1), where_data=["group_id" => group_id, "user_id" => data["user_id"]])
+ dict_users_trade_unions = Dict("user_id" => data["user_id"], "group_id" => group_id)
+ insert_into_table("users_trade_unions",dict_users_trade_unions)
+ compile("trade_unions")
+ return nothing
+end
+
+function reject_request()
+ data = copy(jsonpayload())
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ update_table("trade_unions_requests",Dict("status" => 2), where_data=["group_id" => group_id, "user_id" => data["user_id"]])
+ return nothing
+end
+
+function changeMemberCount()
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ data = copy(jsonpayload())
+ update_table("trade_unions",data, where_data=["id" => group_id])
+ compile("trade_unions")
+end
+
+function change_group()
+ user_id = get_authentication()
+ trade_unions_ids = select_from_table("users_trade_unions" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
+ group_id = isempty(trade_unions_ids) ? nothing : trade_unions_ids[1]
+ if !isnothing(group_id)
+ data = copy(jsonpayload())
+ data_new = Dict()
+ ks = keys(data)
+ for x in ["members","contact"]
+ if x in ks
+ data_new[x] = data[x]
+ end
+ end
+ if !isempty(data_new)
+ update_table("trade_unions",data_new, where_data=["id" => group_id])
+ compile("trade_unions")
+ end
+ end
+ return nothing
+end
+
+
+end
diff --git a/Server/app/resources/trade_unions/views/trade_unions.jl.html b/Server/app/resources/trade_unions/views/trade_unions.jl.html
new file mode 100644
index 0000000..fa97899
--- /dev/null
+++ b/Server/app/resources/trade_unions/views/trade_unions.jl.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Server/app/resources/trade_unions/views/trade_unions_add.jl.html b/Server/app/resources/trade_unions/views/trade_unions_add.jl.html
new file mode 100644
index 0000000..b0d0b6e
--- /dev/null
+++ b/Server/app/resources/trade_unions/views/trade_unions_add.jl.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Server/app/svelte/public/js/libraries/miscTools.js b/Server/app/svelte/public/js/libraries/miscTools.js
index 64af615..0abfbf9 100644
--- a/Server/app/svelte/public/js/libraries/miscTools.js
+++ b/Server/app/svelte/public/js/libraries/miscTools.js
@@ -13,9 +13,9 @@ export function debounce(func, timeout){
}
export function svgFromObject(object) {
- var objectDoc = object.contentDocument;
- var svgItem = objectDoc.querySelector("path");
- return svgItem
+ var objectDoc = object.contentDocument
+ var svgItems = objectDoc.querySelectorAll("path")
+ return svgItems
}
export function rem2px(rem) {
diff --git a/Server/app/svelte/public/js/mapFuncs.js b/Server/app/svelte/public/js/mapFuncs.js
index f37d0d7..b024f03 100644
--- a/Server/app/svelte/public/js/mapFuncs.js
+++ b/Server/app/svelte/public/js/mapFuncs.js
@@ -6,7 +6,15 @@ export function addGroupPinContent(g,content,locale) {
for (let field of ["location","members","contact"]) {
let fieldText = content[field] + ": "
if (field=="contact") {
- text += fieldText + "" + g.contact + ""
+ if (g.contact.includes("@") && g.contact.trim().split(" ").length==1) {
+ text += fieldText + "" + g.contact + ""
+ }
+ else if (g.contact.includes("http")) {
+ text += fieldText + "" + g.contact + ""
+ }
+ else {
+ text += fieldText + g.contact + "
"
+ }
}
else if (field=="location") {
let location = [g.country,g.state,g.town].filter(x => x!=null && x!=undefined)
@@ -175,4 +183,31 @@ export function addPartnersPinContent(g,content,locale) {
}
}
return {text,coordinates}
+}
+
+export function addTradeUnionPinContent(g,content,locale) {
+ let coordinates
+ let text = ""+content["TradeUnion"]+"
"
+ for (let field of ["name","location","members","contact"]) {
+ let fieldText = content[field] + ": "
+ if (field=="contact") {
+ text += fieldText + "" + g.contact + ""
+ }
+ else if (field=="location") {
+ let location = [g.country,g.state,g.town].filter(x => x!=null && x!=undefined)
+ let locationString
+ if (locale=="en") {
+ locationString = location.map(x => x).join(", ")
+ }
+ else {
+ locationString = location.map(x => translate(content, x)).join(", ")
+ }
+ text += fieldText + locationString + "
"
+ coordinates = [g.latitude,g.longitude]
+ }
+ else {
+ text += fieldText + g[field] + "
"
+ }
+ }
+ return {text,coordinates}
}
\ No newline at end of file
diff --git a/Server/app/svelte/public/locales/en/landing-component.json b/Server/app/svelte/public/locales/en/landing-component.json
index 0e807c8..9199c05 100644
--- a/Server/app/svelte/public/locales/en/landing-component.json
+++ b/Server/app/svelte/public/locales/en/landing-component.json
@@ -1,13 +1,15 @@
{
"top": "Our organization is a decentralized federation build upon the principle of free association. It consists of many groups of people united around a cause of bringing down exploitative politico-economic systems. We aim to replace them with libertarian socialist systems based on decentralization, direct democracy and worker-ownership of the means of production with the goal of creating an equitable, democratic and sustainable world by stopping exploitation of humans and nature.",
"groupsTitle": "GROUPS",
- "groupsText": "We organize groups for the purposes of education, advocacy, anti-fascist action and mutual aid. Our objective is to demonstrate how the current politico-economic systems detrimentally impact our well-being, present alternative approaches, and engage in mutual aid to alleviate the challenges of living under capitalism.",
+ "groupsText": "We organize groups for the purposes of education, advocacy, anti-fascist action and mutual aid. Our objective is to demonstrate how the current politico-economic systems detrimentally impact our well-being, present alternative approaches, and engage in mutual aid.",
"communesTitle": "COMMUNES",
"communesText": "We establish communes based on libertarian socialist principles, where commune members have ownership over land, houses, and the means of production as well as make decisions using direct democracy. We are gradually expanding our socialist world, one commune at a time.",
"cooperativesTitle": "COOPERATIVES",
- "cooperativesText": "We form worker cooperatives to finance the operations of our groups and communes. Recognizing that economic power influences political power, we consider the establishment of cooperatives to be one of the initial steps towards achieving socialism.",
+ "cooperativesText": "We form worker cooperatives to finance the operations of our groups and communes. Recognizing that economic power influences political power, we consider the establishment of cooperatives to be a vital activity.",
"partiesTitle": "PARTIES",
"partiesText": "We create political parties in order to push for reforms allowing us to easier further our goals, to move the Overton window as well as to gain popularity. However, we recognize that we cannot achieve libertarian socialism through institutions which act contrary to our goals.",
+ "tradeUnionsTitle": "TRADE UNIONS",
+ "tradeUnionsText": "We promote trade unions, which empower laborers to collectively advocate for fair treatment, just wages, and improved working conditions. Struggle at a place of work is an integral part of our strategy to achieve libertarian socialism.",
"findUs": "Find Us",
"whatNow": "What Now?",
"joinUs": "Join Us",
diff --git a/Server/app/svelte/public/locales/en/navbar-component.json b/Server/app/svelte/public/locales/en/navbar-component.json
index 68b400b..c64073f 100644
--- a/Server/app/svelte/public/locales/en/navbar-component.json
+++ b/Server/app/svelte/public/locales/en/navbar-component.json
@@ -7,6 +7,7 @@
"communes": "Communes",
"cooperatives": "Cooperatives",
"parties": "Parties",
+ "tradeUnions": "Trade Unions",
"partners": "Partners",
"login": "Login",
"profile": "Profile"
diff --git a/Server/app/svelte/public/locales/en/trade-unions-component.json b/Server/app/svelte/public/locales/en/trade-unions-component.json
new file mode 100644
index 0000000..cad5d69
--- /dev/null
+++ b/Server/app/svelte/public/locales/en/trade-unions-component.json
@@ -0,0 +1,11 @@
+{
+ "tradeUnions": "Trade Unions",
+ "p1": "Trade unions play a pivotal role in safeguarding the rights and welfare of workers. Trade unions constitute an integral part of our organization, allowing workers to unite and collectively negotiate for fair wages, better working conditions, and improved labour rights. By fostering solidarity and mobilizing for collective action, trade unions contribute to our overarching mission of dismantling exploitative systems and ushering in a world centered on decentralized decision-making, direct democracy, and worker self-management.",
+ "subheading1": "Our Trade Unions",
+ "location": "Location",
+ "members": "Members",
+ "contact": "Contact",
+ "TradeUnion": "Trade union",
+ "tradeUnion": "trade union",
+ "map-prompt": "Want to appear on our map? Contact us!"
+}
\ No newline at end of file
diff --git a/Server/app/svelte/public/locales/ru/landing-component.json b/Server/app/svelte/public/locales/ru/landing-component.json
index 5eb789b..46c7729 100644
--- a/Server/app/svelte/public/locales/ru/landing-component.json
+++ b/Server/app/svelte/public/locales/ru/landing-component.json
@@ -8,6 +8,8 @@
"cooperativesText": "Мы формируем рабочие кооперативы для финансирования операций наших групп и коммун, а также формирования основы новой социалистической экономики. Признавая, что экономическая власть влияет на политическую власть, мы считаем создание кооперативов одним из первых шагов на пути к социализму.",
"partiesTitle": "ПАРТИИ",
"partiesText": "Мы создаем политические партии, чтобы продвигать реформы, которые позволят легче достичь наших целей, сдвигать окно Овертона и увеличивать нашу популярность. Однако мы признаем, что мы не можем достичь либертарианского социализма с помощью институтов, действующих против наших целей.",
+ "tradeUnionsTitle": "ПРОФСОЮЗЫ",
+ "tradeUnionsText": "Мы поддерживаем профсоюзы, которые дают возможность работникам коллективно выступать за справедливое обращение, справедливую заработную плату и улучшение условий труда. Борьба на месте работы — неотъемлемая часть нашей стратегии по достижению либертарного социализма.",
"findUs": "Найди нас",
"whatNow": "Что теперь?",
"joinUs": "Присоединяйся",
diff --git a/Server/app/svelte/public/locales/ru/navbar-component.json b/Server/app/svelte/public/locales/ru/navbar-component.json
index b1df46c..eef8043 100644
--- a/Server/app/svelte/public/locales/ru/navbar-component.json
+++ b/Server/app/svelte/public/locales/ru/navbar-component.json
@@ -8,6 +8,7 @@
"cooperatives": "Кооперативы",
"parties": "Партии",
"partners": "Партнеры",
+ "tradeUnions": "Профсоюзы",
"login": "Войти",
"profile": "Профиль"
}
\ No newline at end of file
diff --git a/Server/app/svelte/public/locales/ru/trade-unions-component.json b/Server/app/svelte/public/locales/ru/trade-unions-component.json
new file mode 100644
index 0000000..cd53368
--- /dev/null
+++ b/Server/app/svelte/public/locales/ru/trade-unions-component.json
@@ -0,0 +1,11 @@
+{
+ "tradeUnions": "Профсоюзы",
+ "p1": "Профсоюзы играют ключевую роль в защите прав и благосостояния трудящихся. Профсоюзы составляют неотъемлемую часть нашей организации, позволяя работникам объединяться и вести коллективные переговоры о справедливой заработной плате, лучших условиях труда и улучшенных трудовых правах. Укрепляя солидарность и мобилизуя для коллективных действий, профсоюзы вносят свой вклад в нашу всеобъемлющую миссию по устранению эксплуататорских систем и установлению мира, основанного на децентрализованном принятии решений, прямой демократии и самоуправлении рабочих.",
+ "subheading1": "Наши профсоюзы",
+ "location": "Локация",
+ "members": "Участники",
+ "contact": "Контакт",
+ "TradeUnion": "Профсоюз",
+ "tradeUnion": "профсоюз",
+ "map-prompt": "Хочешь оказаться на нашей карте? Напиши нам!"
+}
\ No newline at end of file
diff --git a/Server/app/svelte/src/join-us-component.svelte b/Server/app/svelte/src/join-us-component.svelte
index 2788e66..9cd2b08 100644
--- a/Server/app/svelte/src/join-us-component.svelte
+++ b/Server/app/svelte/src/join-us-component.svelte
@@ -21,6 +21,7 @@
loadLocaleContent(content,"communes-component",loaded)
loadLocaleContent(content,"cooperatives-component",loaded)
loadLocaleContent(content,"parties-component",loaded)
+ loadLocaleContent(content,"trade-unions-component",loaded)
loadLocaleContent(content,"countries",loaded)
let locale = loadLocaleContent(content,"join-us-component",loaded)
@@ -48,6 +49,7 @@
getData("/assets/communes.json",(response) => callback(response,"communes"))
getData("/assets/cooperatives.json",(response) => callback(response,"cooperatives"))
getData("/assets/parties.json",(response) => callback(response,"parties"))
+ getData("/assets/trade-unions.json",(response) => callback(response,"tradeUnions"))
function mapCallback(createMap,content,locale) {
let map = createMap([22, 0],2)
@@ -55,15 +57,19 @@
enableCountryGrouping: true,
}
let groupsMarkersLayer = addMarkersEntries(entries["groups"],entriesByCountry["groups"],map,content,locale,addGroupPinContent,"green",options)
- let communesMarkersLayer = addMarkersEntries(entries["communes"],entriesByCountry["communes"],map,content,locale,addCommunePinContent,"red",options)
- let coopsMarkersLayer = addMarkersEntries(entries["cooperatives"],entriesByCountry["cooperatives"],map,content,locale,addCoopPinContent,"blue",options)
let partiesMarkersLayer = addMarkersEntries(entries["parties"],entriesByCountry["parties"],map,content,locale,addPartyPinContent,"gold",options)
+ let tradeUnionsMarkersLayer = addMarkersEntries(entries["tradeUnions"],entriesByCountry["tradeUnions"],map,content,locale,addPartyPinContent,"violet",options)
+ let coopsMarkersLayer = addMarkersEntries(entries["cooperatives"],entriesByCountry["cooperatives"],map,content,locale,addCoopPinContent,"blue",options)
+ let communesMarkersLayer = addMarkersEntries(entries["communes"],entriesByCountry["communes"],map,content,locale,addCommunePinContent,"red",options)
+
let overlayMaps = {}
overlayMaps[content.groups] = groupsMarkersLayer
- overlayMaps[content.communes] = communesMarkersLayer
- overlayMaps[content.cooperatives] = coopsMarkersLayer
overlayMaps[content.parties] = partiesMarkersLayer
+ overlayMaps[content.tradeUnions] = tradeUnionsMarkersLayer
+ overlayMaps[content.cooperatives] = coopsMarkersLayer
+ overlayMaps[content.communes] = communesMarkersLayer
+
L.control.layers(null, overlayMaps).addTo(map)
}
@@ -73,7 +79,7 @@
{#key $loaded}
- {#if $loaded==10}
+ {#if $loaded==12}
@@ -138,13 +145,16 @@
background-image: url(https://www.libsoc.org/img/common/markers/marker-green.png);
}
#entities-list li:nth-of-type(2):before {
- background-image: url(https://www.libsoc.org/img/common/markers/marker-red.png);
+ background-image: url(https://www.libsoc.org/img/common/markers/marker-gold.png);
}
#entities-list li:nth-of-type(3):before {
- background-image: url(https://www.libsoc.org/img/common/markers/marker-blue.png);
+ background-image: url(https://www.libsoc.org/img/common/markers/marker-violet.png);
}
#entities-list li:nth-of-type(4):before {
- background-image: url(https://www.libsoc.org/img/common/markers/marker-gold.png);
+ background-image: url(https://www.libsoc.org/img/common/markers/marker-blue.png);
+ }
+ #entities-list li:nth-of-type(5):before {
+ background-image: url(https://www.libsoc.org/img/common/markers/marker-red.png);
}
#entities-list li::marker {
diff --git a/Server/app/svelte/src/landing-component.svelte b/Server/app/svelte/src/landing-component.svelte
index 1c01994..5fd7805 100644
--- a/Server/app/svelte/src/landing-component.svelte
+++ b/Server/app/svelte/src/landing-component.svelte
@@ -51,11 +51,14 @@
getData("/assets/communes.json",(response) => callback(response,"communes"))
getData("/assets/cooperatives.json",(response) => callback(response,"cooperatives"))
getData("/assets/parties.json",(response) => callback(response,"parties"))
+ getData("/assets/trade-unions.json",(response) => callback(response,"tradeUnions"))
loadLocaleContent(content,"groups-component",loaded)
loadLocaleContent(content,"communes-component",loaded)
loadLocaleContent(content,"cooperatives-component",loaded)
loadLocaleContent(content,"parties-component",loaded)
+ loadLocaleContent(content,"trade-unions-component",loaded)
+
loadLocaleContent(content,"countries",loaded)
let locale = loadLocaleContent(content,"landing-component",loaded,changeWidth)
changeWidth(locale)
@@ -66,15 +69,18 @@
enableCountryGrouping: true,
}
let groupsMarkersLayer = addMarkersEntries(entries["groups"],entriesByCountry["groups"],map,content,locale,addGroupPinContent,"green",options)
- let communesMarkersLayer = addMarkersEntries(entries["communes"],entriesByCountry["communes"],map,content,locale,addCommunePinContent,"red",options)
- let coopsMarkersLayer = addMarkersEntries(entries["cooperatives"],entriesByCountry["cooperatives"],map,content,locale,addCoopPinContent,"blue",options)
let partiesMarkersLayer = addMarkersEntries(entries["parties"],entriesByCountry["parties"],map,content,locale,addPartyPinContent,"gold",options)
+ let tradeUnionsMarkersLayer = addMarkersEntries(entries["tradeUnions"],entriesByCountry["tradeUnions"],map,content,locale,addPartyPinContent,"violet",options)
+ let coopsMarkersLayer = addMarkersEntries(entries["cooperatives"],entriesByCountry["cooperatives"],map,content,locale,addCoopPinContent,"blue",options)
+ let communesMarkersLayer = addMarkersEntries(entries["communes"],entriesByCountry["communes"],map,content,locale,addCommunePinContent,"red",options)
+
let overlayMaps = {}
overlayMaps[content.groups] = groupsMarkersLayer
- overlayMaps[content.communes] = communesMarkersLayer
- overlayMaps[content.cooperatives] = coopsMarkersLayer
overlayMaps[content.parties] = partiesMarkersLayer
+ overlayMaps[content.tradeUnions] = tradeUnionsMarkersLayer
+ overlayMaps[content.cooperatives] = coopsMarkersLayer
+ overlayMaps[content.communes] = communesMarkersLayer
L.control.layers(null, overlayMaps).addTo(map)
}
@@ -85,7 +91,7 @@
{#key $loaded}
- {#if $loaded==10}
+ {#if $loaded==12}
+
-->
{$content.findUs}
- mapCallback(createMap,$content,locale)} colors={["#23AC20","#CA2437","#217BC9","#FFD326"]}>
+ mapCallback(createMap,$content,locale)} colors={["#23AC20","#FFD326","#9D35CD","#217BC9","#CA2437"]}>
{$content.whatNow}
{$content.joinUs}
@@ -188,7 +199,7 @@
text-align: center;
}
- #groups-img, #communes-img, #coops-img, #parties-img {
+ #groups-img, #communes-img, #coops-img, #parties-img, #trade-unions-img {
position: absolute;
left: 50%;
transform: translate(-50%);
@@ -202,6 +213,11 @@
height: 7.5rem;
}
+ #trade-unions-img {
+ margin-top: 0.5rem;
+ height: 7.5rem;
+ }
+
#text-container {
max-width: calc(100vw - 4rem);
margin: auto;
@@ -230,13 +246,18 @@
#container-grid {
display: grid;
grid-template-columns: var(--grid-width);
- grid-template-rows: var(--grid-width);
+ grid-template-rows: 100% 100%;
grid-gap: 4rem;
row-gap: 2.5rem;
margin-top: 2rem;
margin-bottom: 1rem;
}
+ #container-grid>:last-child {
+ grid-column: 1/span 2;
+
+ }
+
#container-grid > div {
position: relative;
}
diff --git a/Server/app/svelte/src/navbar/navbar-logged.svelte b/Server/app/svelte/src/navbar/navbar-logged.svelte
index 2e547ea..c6bd220 100644
--- a/Server/app/svelte/src/navbar/navbar-logged.svelte
+++ b/Server/app/svelte/src/navbar/navbar-logged.svelte
@@ -115,9 +115,10 @@
diff --git a/Server/app/svelte/src/navbar/navbar-not-logged.svelte b/Server/app/svelte/src/navbar/navbar-not-logged.svelte
index e3004ae..6c106c9 100644
--- a/Server/app/svelte/src/navbar/navbar-not-logged.svelte
+++ b/Server/app/svelte/src/navbar/navbar-not-logged.svelte
@@ -115,9 +115,10 @@
diff --git a/Server/app/svelte/src/profile/profile-component.svelte b/Server/app/svelte/src/profile/profile-component.svelte
index 373d078..5b6fc29 100644
--- a/Server/app/svelte/src/profile/profile-component.svelte
+++ b/Server/app/svelte/src/profile/profile-component.svelte
@@ -15,6 +15,7 @@
import "/js/components/profile-communes.js"
import "/js/components/profile-coops.js"
import "/js/components/profile-parties.js"
+ import "/js/components/profile-trade-unions.js"
import "/js/components/groups-add-component.js"
// Main code
@@ -26,6 +27,7 @@
let communes
let coops
let parties
+ let tradeUnions
let panes
let groupsAdd
@@ -34,6 +36,7 @@
let communesButton
let coopsButton
let partiesButton
+ let tradeUnionsButton
let buttons
let currentPaneIndex = 0
@@ -66,18 +69,21 @@
setTimeout(f,100)
}
else {
- let svgItem = svgFromObject(svgObject)
- if (svgItem==null) {
+ let svgItems = svgFromObject(svgObject)
+ if (svgItems.length==0) {
let f = () => styleField(div,weight,color)
setTimeout(f,100)
}
else {
div.style.fontWeight = weight
- svgItem.setAttribute("fill", color)
+ for (let item of svgItems) {
+ let fill = item.getAttribute("fill")
+ if (fill!="#fff" && fill!=null) {
+ item.setAttribute("fill", color)
+ }
+ }
}
}
-
-
}
function fillFields() {
@@ -98,10 +104,10 @@
function init() {
panes = [general,groups,communes,coops,parties]
- buttons = [generalButton,groupsButton,communesButton,coopsButton,partiesButton]
+ buttons = [generalButton,groupsButton,communesButton,coopsButton,partiesButton,tradeUnionsButton]
if ($loaded==1 && panes.every(x => valid(x)) && buttons.every(x => valid(x))) {
- panes = [general,groups,communes,coops,parties]
- buttons = [generalButton,groupsButton,communesButton,coopsButton,partiesButton]
+ panes = [general,groups,communes,coops,parties,tradeUnions]
+ buttons = [generalButton,groupsButton,communesButton,coopsButton,partiesButton,tradeUnionsButton]
fillFields()
general.style.display = "initial"
@@ -155,6 +161,10 @@
parties
+
diff --git a/Server/app/svelte/src/profile/profile-trade-unions.svelte b/Server/app/svelte/src/profile/profile-trade-unions.svelte
new file mode 100644
index 0000000..66cb1eb
--- /dev/null
+++ b/Server/app/svelte/src/profile/profile-trade-unions.svelte
@@ -0,0 +1,29 @@
+
+
+
+
+Under development
+
+Visit https://discord.gg/Qk8KUk787z and ask for your trade union to be added.
+
+
\ No newline at end of file
diff --git a/Server/app/svelte/src/profile/trade-unions-add-component.svelte b/Server/app/svelte/src/profile/trade-unions-add-component.svelte
new file mode 100644
index 0000000..8bb25ed
--- /dev/null
+++ b/Server/app/svelte/src/profile/trade-unions-add-component.svelte
@@ -0,0 +1,577 @@
+
+
+
+
+{#key $loaded}
+ {#if $loaded==3}
+
+
+
+
+ {#if !has_group}
+
+
+
+
+ {:else if has_group && !pendingGroup}
+
+
+
+
+ {:else}
+
+
+
+ {/if}
+
+ {#key mode}
+ {#if mode==0}
+
+ {/if}
+ {#if mode==0 || mode==1}
+
+ {/if}
+ {/key}
+
+
+ {#if !(has_group && pendingGroup)}
+
mapCallback(createMap,$content,locale)}>
+ {/if}
+
+
+ {/if}
+{/key}
+
+
\ No newline at end of file
diff --git a/Server/app/svelte/src/trade-unions-component.svelte b/Server/app/svelte/src/trade-unions-component.svelte
new file mode 100644
index 0000000..5a15227
--- /dev/null
+++ b/Server/app/svelte/src/trade-unions-component.svelte
@@ -0,0 +1,178 @@
+
+
+
+
+{#key $loaded}
+ {#if $loaded==3}
+
+
+
+
{$content.tradeUnions}
+
+
{$content.p1}
+
{$content.subheading1}
+
mapCallback(createMap,$content,locale)}>
+
{$content["map-prompt"]}
+ {#each Object.entries(entriesByCountry) as [name,entries]}
+
{getCountry(name)}
+
+ {#each entries as entry}
+
+
{$content.name}: {entry.name}
+
{$content.location}: {getAddress(entry)}
+
{$content.members}: {entry.members}
+ {#if entry.contact.includes("@") && entry.contact.trim().split(" ").length==1}
+
{$content.contact}: {entry.contact}
+ {:else if entry.contact.includes("http")}
+
{$content.contact}: {entry.contact}
+ {:else}
+
{$content.contact}: {entry.contact}
+ {/if}
+
+ {/each}
+
+ {/each}
+
+
+ {/if}
+{/key}
+
+
\ No newline at end of file
diff --git a/Server/db/migrations/10_create_table_trade_unions.jl b/Server/db/migrations/10_create_table_trade_unions.jl
new file mode 100644
index 0000000..0ca2627
--- /dev/null
+++ b/Server/db/migrations/10_create_table_trade_unions.jl
@@ -0,0 +1,32 @@
+module CreateTableTradeUnions
+
+import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
+
+include("../../lib/DatabaseSupport.jl")
+import .DatabaseSupport: add_foreign_key
+
+function up()
+ create_table(:trade_unions) do
+ [
+ primary_key()
+ column(:country, :string)
+ column(:state, :string)
+ column(:town, :string)
+ column(:contact, :string)
+ column(:latitude, :float)
+ column(:longitude, :float)
+ column(:name, :string)
+ column(:members, :int)
+ column(:user_id, :int)
+ ]
+ end
+
+ add_foreign_key(:trade_unions,:user_id,:users,:id)
+ add_index(:trade_unions, :user_id)
+end
+
+function down()
+ drop_table(:trade_unions)
+end
+
+end
\ No newline at end of file
diff --git a/Server/db/migrations/2022026611846568_create_table_partners.jl b/Server/db/migrations/11_create_table_partners.jl
similarity index 100%
rename from Server/db/migrations/2022026611846568_create_table_partners.jl
rename to Server/db/migrations/11_create_table_partners.jl
diff --git a/Server/db/migrations/2022026611846569_create_table_groups_requests.jl b/Server/db/migrations/12_create_table_groups_requests.jl
similarity index 94%
rename from Server/db/migrations/2022026611846569_create_table_groups_requests.jl
rename to Server/db/migrations/12_create_table_groups_requests.jl
index f85fda4..d129966 100644
--- a/Server/db/migrations/2022026611846569_create_table_groups_requests.jl
+++ b/Server/db/migrations/12_create_table_groups_requests.jl
@@ -28,8 +28,6 @@ function up()
add_index(:groups_requests, :user_id)
- set_default("groups_requests","added",false)
-
end
function down()
diff --git a/Server/db/migrations/2022026611846570_create_table_communes_requests.jl b/Server/db/migrations/13_create_table_communes_requests.jl
similarity index 100%
rename from Server/db/migrations/2022026611846570_create_table_communes_requests.jl
rename to Server/db/migrations/13_create_table_communes_requests.jl
diff --git a/Server/db/migrations/2022026611846571_create_table_coops_requests.jl b/Server/db/migrations/14_create_table_coops_requests.jl
similarity index 100%
rename from Server/db/migrations/2022026611846571_create_table_coops_requests.jl
rename to Server/db/migrations/14_create_table_coops_requests.jl
diff --git a/Server/db/migrations/2022026611846572_create_table_parties_requests.jl b/Server/db/migrations/15_create_table_parties_requests.jl
similarity index 100%
rename from Server/db/migrations/2022026611846572_create_table_parties_requests.jl
rename to Server/db/migrations/15_create_table_parties_requests.jl
diff --git a/Server/db/migrations/16_create_table_trade_unions_requests.jl b/Server/db/migrations/16_create_table_trade_unions_requests.jl
new file mode 100644
index 0000000..ef49665
--- /dev/null
+++ b/Server/db/migrations/16_create_table_trade_unions_requests.jl
@@ -0,0 +1,38 @@
+module CreateTableTradeUnionsRequests
+
+import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
+
+include("../../lib/DatabaseSupport.jl")
+using .DatabaseSupport
+import .DatabaseSupport: add_foreign_key, set_default
+
+function up()
+ create_table(:trade_unions_requests) do
+ [
+ primary_key()
+ column(:group_id, :integer)
+ column(:user_id, :integer)
+ column(:country, :string)
+ column(:state, :string)
+ column(:town, :string)
+ column(:contact, :string)
+ column(:latitude, :float)
+ column(:longitude, :float)
+ column(:members,:integer)
+ column(:name,:string)
+ column(:status,:integer)
+ ]
+ end
+
+ add_foreign_key(:trade_unions_requests,:user_id,:users,:id)
+ add_foreign_key(:trade_unions_requests,:group_id,:trade_unions,:id)
+
+ add_index(:trade_unions_requests, :user_id)
+
+end
+
+function down()
+ drop_table(:trade_unions_requests)
+end
+
+end
\ No newline at end of file
diff --git a/Server/db/migrations/2022026611846573_create_table_groups_users.jl b/Server/db/migrations/17_create_table_groups_users.jl
similarity index 100%
rename from Server/db/migrations/2022026611846573_create_table_groups_users.jl
rename to Server/db/migrations/17_create_table_groups_users.jl
diff --git a/Server/db/migrations/2022026611846574_create_table_communes_users.jl b/Server/db/migrations/18_create_table_communes_users.jl
similarity index 100%
rename from Server/db/migrations/2022026611846574_create_table_communes_users.jl
rename to Server/db/migrations/18_create_table_communes_users.jl
diff --git a/Server/db/migrations/2022026611846575_create_table_cooperatives_users.jl b/Server/db/migrations/19_create_table_cooperatives_users.jl
similarity index 100%
rename from Server/db/migrations/2022026611846575_create_table_cooperatives_users.jl
rename to Server/db/migrations/19_create_table_cooperatives_users.jl
diff --git a/Server/db/migrations/2019052410085235_create_table_users.jl b/Server/db/migrations/1_create_table_users.jl
similarity index 100%
rename from Server/db/migrations/2019052410085235_create_table_users.jl
rename to Server/db/migrations/1_create_table_users.jl
diff --git a/Server/db/migrations/2022026611846576_create_table_parties_users.jl b/Server/db/migrations/20_create_table_parties_users.jl
similarity index 100%
rename from Server/db/migrations/2022026611846576_create_table_parties_users.jl
rename to Server/db/migrations/20_create_table_parties_users.jl
diff --git a/Server/db/migrations/2022026611846577_create_table_users_groups.jl b/Server/db/migrations/21_create_table_users_groups.jl
similarity index 100%
rename from Server/db/migrations/2022026611846577_create_table_users_groups.jl
rename to Server/db/migrations/21_create_table_users_groups.jl
diff --git a/Server/db/migrations/22_create_table_trade_unions_users.jl b/Server/db/migrations/22_create_table_trade_unions_users.jl
new file mode 100644
index 0000000..4dcbd47
--- /dev/null
+++ b/Server/db/migrations/22_create_table_trade_unions_users.jl
@@ -0,0 +1,24 @@
+module CreateTableTradeUnionsUsers
+
+import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
+
+function up()
+ create_table(:trade_unions_users) do
+ [
+ primary_key()
+ column(:user_id, :int)
+ column(:trade_union_id, :int)
+ ]
+ end
+
+ add_foreign_key(:trade_unions_users,:user_id,:users,:id)
+ add_foreign_key(:trade_unions_users,:trade_union_id,:trade_unions,:id)
+ add_index(:trade_unions_users, :user_id)
+ add_index(:trade_unions_users, :trade_union_id)
+end
+
+function down()
+ drop_table(:trade_unions_users)
+end
+
+end
\ No newline at end of file
diff --git a/Server/db/migrations/2021061519495560_create_table_roles.jl b/Server/db/migrations/2_create_table_roles.jl
similarity index 100%
rename from Server/db/migrations/2021061519495560_create_table_roles.jl
rename to Server/db/migrations/2_create_table_roles.jl
diff --git a/Server/db/migrations/2021061519503270_create_table_permissions.jl b/Server/db/migrations/3_create_table_permissions.jl
similarity index 100%
rename from Server/db/migrations/2021061519503270_create_table_permissions.jl
rename to Server/db/migrations/3_create_table_permissions.jl
diff --git a/Server/db/migrations/2021061519532446_create_table_roles_users.jl b/Server/db/migrations/4_create_table_roles_users.jl
similarity index 100%
rename from Server/db/migrations/2021061519532446_create_table_roles_users.jl
rename to Server/db/migrations/4_create_table_roles_users.jl
diff --git a/Server/db/migrations/2021061519540214_create_table_permissions_roles.jl b/Server/db/migrations/5_create_table_permissions_roles.jl
similarity index 100%
rename from Server/db/migrations/2021061519540214_create_table_permissions_roles.jl
rename to Server/db/migrations/5_create_table_permissions_roles.jl
diff --git a/Server/db/migrations/2022026611846565_create_table_groups.jl b/Server/db/migrations/6_create_table_groups.jl
similarity index 100%
rename from Server/db/migrations/2022026611846565_create_table_groups.jl
rename to Server/db/migrations/6_create_table_groups.jl
diff --git a/Server/db/migrations/2022026611846566_create_table_communes.jl b/Server/db/migrations/7_create_table_communes.jl
similarity index 100%
rename from Server/db/migrations/2022026611846566_create_table_communes.jl
rename to Server/db/migrations/7_create_table_communes.jl
diff --git a/Server/db/migrations/2022026611846567_create_table_cooperatives.jl b/Server/db/migrations/8_create_table_cooperatives.jl
similarity index 100%
rename from Server/db/migrations/2022026611846567_create_table_cooperatives.jl
rename to Server/db/migrations/8_create_table_cooperatives.jl
diff --git a/Server/db/migrations/2022026611846567_create_table_parties.jl b/Server/db/migrations/9_create_table_parties.jl
similarity index 100%
rename from Server/db/migrations/2022026611846567_create_table_parties.jl
rename to Server/db/migrations/9_create_table_parties.jl
diff --git a/Server/public/assets/trade-unions.json b/Server/public/assets/trade-unions.json
new file mode 100644
index 0000000..0637a08
--- /dev/null
+++ b/Server/public/assets/trade-unions.json
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/Server/public/img/common/coops.svg b/Server/public/img/common/coops.svg
index 9e4b1c2..6732046 100644
--- a/Server/public/img/common/coops.svg
+++ b/Server/public/img/common/coops.svg
@@ -1,3 +1,3 @@
-