Skip to content

Commit

Permalink
contributors tables fixes (#8021)
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Jun 11, 2020
1 parent 437deb9 commit 93d9b95
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 92 deletions.
52 changes: 27 additions & 25 deletions app/views/tag/_contributors.html.erb
Expand Up @@ -34,33 +34,35 @@
<% elsif @note_count.nil? || @note_count == 0 %>
<p><%= raw translation('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% else %>
<div class="col-md-6" style="display: inline-block;">
<table class="table">
<tr>
<th style="width:75%;"><%= translation('tag.contributors.people_who\'ve_posted') %></th>
<th><%= translation('tag.contributors.notes') %></th>
</tr>
<% if @users %>
<% @users.each do |user| %>
<tr class="users-row">
<td><a href='/profile/<%= user.name %>'><i class="fa fa-user"></i> <%= user.name %></a></td>
<td><a href='/tag/<%= params[:id] %>/author/<%= user.name %>'><%= translation('tag.contributors.notes') %> &raquo;</a></td>
</tr>
<div class="row">
<div class="col-md-6">
<table class="table">
<tr>
<th style="width:75%;"><%= translation('tag.contributors.people_who\'ve_posted') %></th>
<th><%= translation('tag.contributors.notes') %></th>
</tr>
<% if @users %>
<% @users.each do |user| %>
<tr class="users-row">
<td><a href='/profile/<%= user.name %>'><i class="fa fa-user"></i> <%= user.name %></a></td>
<td><a href='/tag/<%= params[:id] %>/author/<%= user.name %>'><%= translation('tag.contributors.notes') %> &raquo;</a></td>
</tr>
<% end %>
<% end %>
<% end %>
</table>
</div>
<div class="col-md-6" style="display: inline-table; position:absolute">
<table class="table">
<tr>
<th> <%= translation('tag.contributors.people_who_are_following') %> </th>
</tr>
<% Tag.followers(params[:id]) && Tag.followers(params[:id]).each do |follower| %>
<tr class="followers-row">
<td><a href='/profile/<%= follower.name %>'><i class="fa fa-user-o"></i> <%= follower.name %></a></td>
</table>
</div>
<div class="col-md-6">
<table class="table">
<tr>
<th> <%= translation('tag.contributors.people_who_are_following') %> </th>
</tr>
<% end %>
</table>
<% Tag.followers(params[:id]) && Tag.followers(params[:id]).each do |follower| %>
<tr class="followers-row">
<td><a href='/profile/<%= follower.name %>'><i class="fa fa-user-o"></i> <%= follower.name %></a></td>
</tr>
<% end %>
</table>
</div>
</div>
<br />
<% end %>
121 changes: 60 additions & 61 deletions app/views/tag/contributors.html.erb
@@ -1,69 +1,68 @@
<div class="col-lg-9">
<% if @tag %>
<div id="note-graph" style="height:100px;"></div>
<div class="col-12">
<% if @tag %>
<div id="note-graph" style="height:100px;"></div>

<script src="https://cdn.jsdelivr.net/npm/frappe-charts@0.0.8/dist/frappe-charts.min.iife.js"></script>
<script type="text/javascript">
var notes = <%= @tag.contribution_graph_making.to_a.sort.to_json %>
let months = ["J", "F", "M", "A", "M", "J", "J", "A","S", "O", "N", "D"];
let i;
let labels = new Array();
for(i = 0; i < notes.length; i++)
labels[i] = "";
let count = 0;
let prev = 0;
for(i = 0; i < notes.length; i++){
if(notes[i][1][0] != prev){
if(count == 4){
let j;
labels[i - 2] = months[prev - 1];
}
else{
labels[i - 3] = months[prev - 1];
}
prev = notes[i][1][0];
count = 0;
}
count++;
}
if(count >= 3){
labels[notes.length - 3] = months[prev - 1];
}
let title = "note";
let values = new Array();
for (j = 0; j < notes.length; j++){
values[j] = notes[j][1][1];
}
let data = new Object();
data.labels = labels;
let datasets = new Array();
let obj = new Object();
obj.title = title;
obj.values = new Array();
obj.values = values;
datasets[0] = new Object();
datasets[0] = obj;
data.datasets = datasets;
let chart = new Chart({
parent: "#note-graph",
data: data,
type: "bar",
height: 115,
x_axis_mode: "tick",
y_axis_mode: "span",
is_series: 1,
colors: ['purple']
});
</script>
<script src="https://cdn.jsdelivr.net/npm/frappe-charts@0.0.8/dist/frappe-charts.min.iife.js"></script>
<script type="text/javascript">
var notes = <%= @tag.contribution_graph_making.to_a.sort.to_json %>
let months = ["J", "F", "M", "A", "M", "J", "J", "A","S", "O", "N", "D"];
let i;
let labels = new Array();
for(i = 0; i < notes.length; i++)
labels[i] = "";
let count = 0;
let prev = 0;
for(i = 0; i < notes.length; i++){
if(notes[i][1][0] != prev){
if(count == 4){
let j;
labels[i - 2] = months[prev - 1];
}
else{
labels[i - 3] = months[prev - 1];
}
prev = notes[i][1][0];
count = 0;
}
count++;
}
if(count >= 3){
labels[notes.length - 3] = months[prev - 1];
}
let title = "note";
let values = new Array();
for (j = 0; j < notes.length; j++){
values[j] = notes[j][1][1];
}
let data = new Object();
data.labels = labels;
let datasets = new Array();
let obj = new Object();
obj.title = title;
obj.values = new Array();
obj.values = values;
datasets[0] = new Object();
datasets[0] = obj;
data.datasets = datasets;
let chart = new Chart({
parent: "#note-graph",
data: data,
type: "bar",
height: 115,
x_axis_mode: "tick",
y_axis_mode: "span",
is_series: 1,
colors: ['purple']
});
</script>

<br />

<h3 style="margin-top:0;"><%= raw translation('tag.contributors.contributors_for', :tag_name => params[:id]) %></h3>
<p><%= translation('tag.contributors.contributions_over_past_year') %></p>
<h3 style="margin-top:0;"><%= raw translation('tag.contributors.contributors_for', :tag_name => params[:id]) %></h3>
<p><%= translation('tag.contributors.contributions_over_past_year') %></p>

<% end %>
<% end %>
<%= render :partial => "tag/contributors" %>
<%= render partial: "tag/contributors" %>

</div>
<%= render :partial => "sidebar/related" %>
2 changes: 1 addition & 1 deletion app/views/tag/show.html.erb
Expand Up @@ -49,7 +49,7 @@
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-9">
<div class="col-lg-9">

<%= render partial: 'tag/show/contributors' %>

Expand Down
6 changes: 1 addition & 5 deletions app/views/tag/show/_tab_content.html.erb
Expand Up @@ -53,11 +53,7 @@
<% if @node_type == "contributors" %>
<div class="tab-pane active" id="contributors">
<div class="row">
<div class="col-md-9" style="padding-left: 46px">
<%= render partial: "tag/contributors" %>
</div>
</div>
<%= render partial: "tag/contributors" %>
</div>
<% end %>
<br />
Expand Down

0 comments on commit 93d9b95

Please sign in to comment.