Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor toolbar into v-authorship tab #566

Merged
merged 26 commits into from Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a387e19
wip
ongspxm Feb 21, 2019
4fc1151
deactivating the tab
ongspxm Feb 21, 2019
3fcd62b
remove js for button update
ongspxm Feb 21, 2019
9e73331
move expand func to v_authorship
ongspxm Feb 21, 2019
c66a3ee
wip. left with updateCount
ongspxm Feb 21, 2019
7dbb41b
updateCount using document.getElementsByClassName
ongspxm Feb 21, 2019
b813aa2
wrap everything within v-authorship
ongspxm Feb 21, 2019
a7aeefd
fix lint
ongspxm Feb 21, 2019
4bb21d6
updated to use isTabActive instead of tabActive to trigger tab display
ongspxm Feb 22, 2019
b632566
added TODO to remove change
ongspxm Feb 24, 2019
6b718c7
Merge branch 'master' into tabs
yamidark Feb 25, 2019
d355cf2
make tick box update the activeFile values manually
ongspxm Feb 26, 2019
7d9a3c5
Merge branch 'tabs' of github.com:ongspxm/reposense into tabs
ongspxm Feb 26, 2019
0b6759d
use setTimeout to stagger updateCount for update
ongspxm Feb 26, 2019
7f8b82c
rename variable activeFiles
ongspxm Feb 28, 2019
02863ea
triple eqs
ongspxm Feb 28, 2019
71b9273
Merge remote-tracking branch 'upstream/master' into tabs
ongspxm Feb 28, 2019
8d6c0ca
changed name to tabType
ongspxm Mar 1, 2019
69370e6
minor nits
ongspxm Mar 3, 2019
fce473d
Merge branch 'master' into tabs
ongspxm Mar 7, 2019
2bd1a05
minor nits on equality signs
ongspxm Mar 7, 2019
e20002b
minor nit
ongspxm Mar 10, 2019
74144b0
Merge branch 'master' into tabs
yamidark Mar 12, 2019
50edcaa
Merge branch 'master' into tabs
ongspxm Mar 12, 2019
0998b04
fix: err in merge
ongspxm Mar 12, 2019
4e3ed4a
Merge branch 'tabs' of github.com:ongspxm/reposense into tabs
ongspxm Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions frontend/src/index.jade
Expand Up @@ -41,13 +41,10 @@ html
i.fas.fa-caret-right
.tab-content
.tab-panes
#tab-authorship.tab-pane(v-if="isTabAuthorship")
.toolbar(v-if="tabInfo.tabAuthorship.totalCommits > 0")
a(v-if="isCollapsed", v-on:click="expand(true)") Expand all
a(v-else, v-on:click="expand(false)") Collapse all
v_authorship(
v-bind:key="generateKey(tabInfo.tabAuthorship)",
v-bind:info="tabInfo.tabAuthorship")
v_authorship#tab-authorship.tab-pane(
v-if="tabType === 'authorship'"
v-bind:key="generateKey(tabInfo.tabAuthorship)",
v-bind:info="tabInfo.tabAuthorship")
#tab-empty.tab-pane(v-else)
.title
span To view the code attributed to a specific author, click the  
Expand Down Expand Up @@ -199,6 +196,10 @@ html

vuetemplate#v_authorship
#authorship
// TODO: remove in #524
.toolbar(v-if="info.totalCommits > 0")
ongspxm marked this conversation as resolved.
Show resolved Hide resolved
a(v-if="activeFileCount === 0", v-on:click="expandAll(true)") Expand all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untitled

Seems like this activeFileCount variable hasn't been refactored to latest master?

a(v-else, v-on:click="expandAll(false)") Collapse all
.title
a.repoName(
v-bind:href="info.location", target="_blank",
Expand Down Expand Up @@ -226,11 +227,11 @@ html
span.bloc(v-bind:title="getFileBlankLineInfo(format)") ({{ filesBlankLinesObj[format] }})

.files(v-if="isLoaded")
.empty(v-if="files.length===0") nothing to see here :(
.empty(v-if="files.length === 0") nothing to see here :(
template(v-for="file in selectedFiles")
.file.active(v-bind:key="file.path")
.title
span.path(onclick="toggleNext(this.parentNode)") {{ file.path }} 
span.path(onclick="toggleNext(this.parentNode)", v-on:click="updateCount") {{ file.path }} 
span.loc ({{ file.lineCount }} lines)
a(
v-bind:href="getFileLink(file, 'commits')", target="_blank",
Expand Down
26 changes: 11 additions & 15 deletions frontend/src/static/js/main.js
Expand Up @@ -99,10 +99,10 @@ window.app = new window.Vue({

isLoading: false,
isCollapsed: false,
isTabActive: true,
isTabAuthorship: false,
isTabActive: true, // to force tab wrapper to load
ongspxm marked this conversation as resolved.
Show resolved Hide resolved

tabType: 'empty',
tabInfo: {},
tabAuthorship: {},
creationDate: '',
},
methods: {
Expand Down Expand Up @@ -154,26 +154,22 @@ window.app = new window.Vue({
});
return full;
},
deactivateTabs() {
this.isTabAuthorship = false;

deactivateTab() {
this.isTabActive = false;
if (document.getElementById('tabs-wrapper')) {
document.getElementById('tabs-wrapper').scrollTop = 0;
}
},

updateTabAuthorship(obj) {
this.deactivateTabs();
this.deactivateTab();
this.tabInfo.tabAuthorship = Object.assign({}, obj);

this.isTabActive = true;
this.isTabAuthorship = true;
this.isCollapsed = false;
if (document.getElementById('tabs-wrapper')) {
document.getElementById('tabs-wrapper').scrollTop = 0;
}
},

/* global expandAll */
expand(isActive) {
this.isCollapsed = !isActive;
expandAll(isActive);
this.tabType = 'authorship';
},

generateKey(dataObj) {
Expand Down
46 changes: 22 additions & 24 deletions frontend/src/static/js/v_authorship.js
Expand Up @@ -13,26 +13,6 @@ window.toggleNext = function toggleNext(ele) {
}

parent.className = classes.join(' ');

// Update expand/collapse all button
window.updateToggleButton();
};

window.updateToggleButton = function updateToggleButton() {
if (document.getElementsByClassName('file active').length === document.getElementsByClassName('file').length) {
window.app.isCollapsed = false;
} else if (document.getElementsByClassName('file active').length === 0) {
window.app.isCollapsed = true;
}
};

window.expandAll = function expandAll(isActive) {
const renameValue = isActive ? 'file active' : 'file';

const files = document.getElementsByClassName('file');
Array.from(files).forEach((file) => {
file.className = renameValue;
});
};

const repoCache = [];
Expand All @@ -51,6 +31,7 @@ window.vAuthorship = {
filesBlankLinesObj: {},
totalLineCount: '',
totalBlankLineCount: '',
activeFilesCount: 0,
filterSearch: '*',
};
},
Expand All @@ -75,6 +56,21 @@ window.vAuthorship = {
}
},

expandAll(isActive) {
const renameValue = isActive ? 'file active' : 'file';

const files = document.getElementsByClassName('file');
Array.from(files).forEach((file) => {
file.className = renameValue;
});

this.activeFilesCount = isActive ? this.selectedFiles.length : 0;
},

updateCount() {
this.activeFilesCount = document.getElementsByClassName('file active').length;
},

splitSegments(lines) {
// split into segments separated by authored
let lastState;
Expand Down Expand Up @@ -144,6 +140,8 @@ window.vAuthorship = {
this.filesBlankLinesObj = filesBlanksInfoObj;
this.files = res;
this.isLoaded = true;

this.activeFilesCount = this.selectedFiles.length;
},

addBlankLineCountToFileFormat(path, lineCount, filesInfoObj) {
Expand All @@ -160,8 +158,10 @@ window.vAuthorship = {
selectAll() {
if (!this.isSelectAllChecked) {
this.selectedFileFormats = this.fileFormats.slice();
this.activeFilesCount = this.files.length;
} else {
this.selectedFileFormats = [];
this.activeFilesCount = 0;
}
},

Expand All @@ -180,6 +180,8 @@ window.vAuthorship = {
} else if (this.selectedFileFormats.length === 0) {
this.isSelectAllChecked = false;
}

setTimeout(this.updateCount, 0);
},

updateFilterSearch(evt) {
Expand Down Expand Up @@ -260,8 +262,4 @@ window.vAuthorship = {
created() {
this.initiate();
},

updated() {
window.updateToggleButton();
},
};