-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Soulou/new_admin_backoffice
(PR) Administrator : Redesign of the backoffice
- Loading branch information
Showing
42 changed files
with
1,006 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This is a manifest file that'll be compiled into including all the files listed below. | ||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically | ||
// be included in the compiled file accessible from http://example.com/assets/application.js | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// the compiled file. | ||
// | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require bootstrap | ||
//= require bootstrap-datepicker/core | ||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr | ||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.de | ||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.es | ||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.uk | ||
//= require select2 | ||
//= require underscore | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$ -> | ||
formatOptionCandidate = (candidate) -> | ||
'<img src="https://voxe.s3.amazonaws.com/candidates/' + candidate.text.replace(/\s+/, "-") + '-50.jpg"> ' + candidate.text | ||
$("#candidacy_candidates").select2 | ||
width: "250px" | ||
formatResult: formatOptionCandidate | ||
formatSelection: formatOptionCandidate | ||
escapeMarkup: (m) -> m | ||
|
148 changes: 148 additions & 0 deletions
148
app/assets/javascripts/new_admin/election_tags.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
$ -> | ||
# Prevent from sending form | ||
$("#form-tag-search").on "submit", (e) -> | ||
e.preventDefault() | ||
|
||
# Listen on keyup to trigger tags filtering | ||
$("#tag-search").on "keyup", (e) -> | ||
input = $(this).val().toLowerCase() | ||
if (e.keyCode > 32 && e.keyCode < 128) || e.keyCode == 8 | ||
filterTags(input) | ||
|
||
filterTags = (input) -> | ||
filterTagsTree($('.root-tag'), input) | ||
|
||
matchTagName = (tag, input) -> | ||
tag.children().first().text().toLowerCase().search(input) != -1 | ||
|
||
filterTagsTree = (tags, input) -> | ||
_.reduce(tags, (acc, tag) -> | ||
$tag = $(tag) | ||
# If the name matches or if a subnode matches | ||
# the input We keep the parent node | ||
if filterTagsTree($tag.find("li"), input) || matchTagName($tag, input) | ||
$tag.show() | ||
acc || true | ||
else | ||
$tag.hide() | ||
acc || false | ||
, false) | ||
|
||
getTag = (id, cb) -> | ||
$.ajax | ||
url: '/api/v1/tags/' + id | ||
method: 'GET' | ||
success: (response, status, xhr) -> | ||
cb(response.response.tag) | ||
error: (xhr, status, body) -> | ||
cb({}) | ||
|
||
buildTagsSelect = (select, filterIds) -> | ||
filterIds = [] | ||
$(".tag").each -> | ||
filterIds.push this.id | ||
select.select2 | ||
ajax: | ||
url: '/api/v1/tags/search' | ||
dataType: 'json' | ||
placeholder: "Search for a tag" | ||
minimumInputLength: 1 | ||
data: (term, page) -> | ||
name: term | ||
results: (data, page) -> | ||
results: _.filter data.response, (tag) -> | ||
filterIds.indexOf(tag.id) == -1 | ||
formatResult: (tag) -> | ||
tag.name | ||
formatSelection: (tag) -> | ||
tag.name | ||
|
||
buildNewTag = (elem) -> | ||
# Build our tag and add it to the page | ||
# We first check who's the parent node to manage the class | ||
buttons = $("<button></button>").text("-").addClass("btn").addClass("rm-tag").on("click", removeTag) | ||
addButton = $("<button></button>").text("+").addClass("btn").addClass("add-tag").on("click", addTag) | ||
classes = $(elem).parent().parent().attr "class" | ||
if classes.indexOf("container-fluid") != -1 | ||
tag_class = "root-tag" | ||
buttons = buttons.before addButton | ||
else if classes.indexOf("root-tag") != -1 | ||
tag_class = "sub-tag" | ||
buttons = buttons.before addButton | ||
else if classes.indexOf("sub-tag") != -1 | ||
tag_class = "sub-sub-tag" | ||
|
||
# We create the HTML tag directly | ||
$("<li></li>"). | ||
addClass(tag_class). | ||
addClass("tag"). | ||
addClass("span2"). | ||
attr("id", elem.tag.id). | ||
append( | ||
$("<div></div>"). | ||
addClass("tag-name"). | ||
text(elem.tag.name). | ||
append(buttons) | ||
). | ||
append($("<ul></ul>")) | ||
|
||
addRootTag = (e) -> | ||
select = $("<div></div>") | ||
$(this).parent().append(select) | ||
buildTagsSelect(select) | ||
select.on "change", (e) => | ||
getTag e.val, (tag) => | ||
@tag = tag | ||
$.ajax | ||
url: '/api/v1/elections/'+ $(".election-tags").attr("id") + '/addtag' | ||
type: 'POST' | ||
data: | ||
tagId: tag.id | ||
success: (response, status, xhr) => | ||
select.select2("destroy") | ||
$(".election-tags").prepend buildNewTag(@) | ||
|
||
addTag = (e) -> | ||
select = $("<div></div>") | ||
$(this).parent().append(select) | ||
buildTagsSelect(select) | ||
|
||
select.on "change", (e) => | ||
getTag e.val, (tag) => | ||
if tag == {} | ||
false | ||
else | ||
@tag = tag | ||
$.ajax | ||
url: '/api/v1/elections/'+ $(".election-tags").attr("id") + '/addtag' | ||
type: 'POST' | ||
data: | ||
tagId: tag.id | ||
parentTagId: $(this).parent().parent().attr("id") | ||
success: (response, status, xhr) => | ||
# Remove select2, we don't need it anymore | ||
select.select2("destroy") | ||
$(this).parent().next().prepend buildNewTag(@) | ||
error: (response, status, body) -> | ||
if $(".alert").size() == 0 | ||
$("body .container-fluid").prepend $('<div class="alert alert-error"></div>') | ||
$(".alert").text(response.responseText) | ||
$(".alert").show() | ||
|
||
removeTag = (e) -> | ||
$.ajax | ||
url: '/api/v1/elections/' + $(".election-tags").attr("id") + '/removetag' | ||
type: 'DELETE' | ||
data: | ||
tagId: $(this).parent().parent().attr('id') | ||
success: (response, status, body) => | ||
$(this).parent().parent().remove() | ||
error: (response, status, body) => | ||
if response.status == 200 | ||
$(this).parent().parent().remove() | ||
|
||
|
||
$(".add-root-tag").on "click", addRootTag | ||
$(".add-tag").on "click", addTag | ||
$(".rm-tag").on "click", removeTag | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$ -> | ||
$("#election_name").on "keyup", (e) -> | ||
$("#election_namespace").val( | ||
$(this).val().toLowerCase().replace /\s+/g, '-' | ||
) | ||
|
||
$("#election_namespace").on "keypress", (e) -> | ||
$("#election_name").off "keyup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* This is a manifest file that'll automatically include all the stylesheets available in this directory | ||
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at | ||
* the top of the compiled file, but it's generally better to create a new file per style scope. | ||
* | ||
*= require_tree . | ||
*= require_self | ||
*= require bootstrap | ||
*= require bootstrap-datepicker | ||
*= require select2 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
$candidacy_height: 50px | ||
$candidacy_width: 250px | ||
$candidacy_link_width: 220px | ||
$candidacy_delete_padding: ($candidacy_width - $candidacy_link_width) / 2 | ||
$candidacy_border_size: 1px | ||
$candidacy_border_color: #c2c2c2 | ||
$candidacy_published_color: #DCF7E3 | ||
$candidacy_unpublished_color: #F2D3D3 | ||
|
||
|
||
.candidacy | ||
border: $candidacy_border_size solid $candidacy_border_color | ||
display: inline-block | ||
width: $candidacy_width | ||
a | ||
display: inline-block | ||
height: $candidacy_height | ||
width: $candidacy_link_width | ||
vertical-align: middle | ||
&.candidacy-published | ||
background-color: $candidacy_published_color | ||
&.candidacy-unpublished | ||
background-color: $candidacy_unpublished_color | ||
&.candidacy-delete | ||
border-left: $candidacy_border_size solid darken($candidacy_border_color, 20%) | ||
float: right | ||
text-align: center | ||
height: 100% | ||
padding-top: $candidacy_delete_padding | ||
padding-bottom: $candidacy_delete_padding | ||
font-size: 40px | ||
color: darken($candidacy_unpublished_color, 40%) | ||
width: $candidacy_width - $candidacy_link_width - $candidacy_border_size | ||
background-color: darken($candidacy_unpublished_color, 20%) | ||
|
||
#s2id_candidacy_candidates .select2-choice | ||
height: 50px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
img.flag | ||
height: 30px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.election-publication | ||
display: block | ||
width: 30px | ||
height: 30px | ||
border-radius: 15px | ||
|
||
a.election-published | ||
@extend .election-publication | ||
background-color: green | ||
box-shadow: 1px 1px 3px 3px rgba(0, 0, 0, 0.5) inset | ||
|
||
a.election-unpublished | ||
@extend .election-publication | ||
background-color: red | ||
box-shadow: -1px 2px 3px 1px rgba(0, 0, 0, 0.9), -1px 2px 10px rgba(255, 255, 255, 0.6) inset | ||
|
||
#s2id_election_country_id | ||
width: 224px |
Oops, something went wrong.