Merge pull request #565 from sharelatex/as-dash-action-btns

Add action buttons to v2 dash
This commit is contained in:
Alasdair Smith 2018-05-31 10:11:20 +01:00 committed by GitHub
commit 57c56a0853
5 changed files with 92 additions and 20 deletions

View file

@ -1,4 +1,7 @@
.col-xs-6 - var titleClasses = settings.overleaf ? "col-xs-6 col-sm-4 col-md-6" : "col-xs-6"
- var lastUpdatedClasses = settings.overleaf ? " col-xs-4 col-sm-3 col-md-2" : "col-xs-4"
div(class=titleClasses)
input.select-item( input.select-item(
select-individual, select-individual,
type="checkbox", type="checkbox",
@ -37,8 +40,42 @@
tooltip-placement="right" tooltip-placement="right"
tooltip-append-to-body="true" tooltip-append-to-body="true"
) )
.col-xs-4
div(class=lastUpdatedClasses)
if settings.overleaf if settings.overleaf
span.last-modified(tooltip="{{project.lastUpdated | formatDate}}") {{project.lastUpdated | fromNowDate}} span.last-modified(tooltip="{{project.lastUpdated | formatDate}}") {{project.lastUpdated | fromNowDate}}
else else
span.last-modified {{project.lastUpdated | formatDate}} span.last-modified {{project.lastUpdated | formatDate}}
if settings.overleaf
.hidden-xs.col-sm-3.col-md-2.action-btn-row
button.btn.btn-link.action-btn(
tooltip=translate('copy'),
tooltip-placement="top",
tooltip-append-to-body="true",
ng-click="clone($event)"
)
i.icon.fa.fa-files-o
button.btn.btn-link.action-btn(
tooltip=translate('download'),
tooltip-placement="top",
tooltip-append-to-body="true",
ng-click="download($event)"
)
i.icon.fa.fa-cloud-download
button.btn.btn-link.action-btn(
ng-if="!project.archived"
tooltip=translate('archive'),
tooltip-placement="top",
tooltip-append-to-body="true",
ng-click="archive($event)"
)
i.icon.fa.fa-inbox
button.btn.btn-link.action-btn(
ng-if="project.archived"
tooltip=translate('unarchive'),
tooltip-placement="top",
tooltip-append-to-body="true",
ng-click="restore($event)"
)
i.icon.fa.fa-reply

View file

@ -131,7 +131,10 @@
) )
li.container-fluid li.container-fluid
.row .row
.col-xs-6 - var titleClasses = settings.overleaf ? " col-xs-6 col-sm-4 col-md-6" : "col-xs-6"
- var lastUpdatedClasses = settings.overleaf ? " col-xs-4 col-sm-3 col-md-2" : "col-xs-4"
div(class=titleClasses)
input.select-all( input.select-all(
select-all, select-all,
type="checkbox" type="checkbox"
@ -142,9 +145,12 @@
.col-xs-2 .col-xs-2
span.header.clickable(ng-click="changePredicate('accessLevel')") #{translate("owner")} span.header.clickable(ng-click="changePredicate('accessLevel')") #{translate("owner")}
i.tablesort.fa(ng-class="getSortIconClass('accessLevel')") i.tablesort.fa(ng-class="getSortIconClass('accessLevel')")
.col-xs-4 div(class=lastUpdatedClasses)
span.header.clickable(ng-click="changePredicate('lastUpdated')") #{translate("last_modified")} span.header.clickable(ng-click="changePredicate('lastUpdated')") #{translate("last_modified")}
i.tablesort.fa(ng-class="getSortIconClass('lastUpdated')") i.tablesort.fa(ng-class="getSortIconClass('lastUpdated')")
if settings.overleaf
.hidden-xs.col-sm-3.col-md-2.action-btn-row-header
span.header #{translate("actions")}
li.project_entry.container-fluid( li.project_entry.container-fluid(
ng-repeat="project in visibleProjects | orderBy:predicate:reverse", ng-repeat="project in visibleProjects | orderBy:predicate:reverse",
ng-controller="ProjectListItemController" ng-controller="ProjectListItemController"

View file

@ -1,4 +1,4 @@
.col-xs-6 .col-xs-6.col-sm-4.col-md-6
.select-item .select-item
span.v1-badge( span.v1-badge(
aria-label=translate("v1_badge") aria-label=translate("v1_badge")
@ -21,5 +21,5 @@
.col-xs-2 .col-xs-2
span.owner {{ownerName()}} span.owner {{ownerName()}}
.col-xs-4 .col-xs-4.col-sm-3.col-md-2
span.last-modified(tooltip="{{project.lastUpdated | formatDate}}") {{project.lastUpdated | fromNowDate}} span.last-modified(tooltip="{{project.lastUpdated | formatDate}}") {{project.lastUpdated | fromNowDate}}

View file

@ -350,14 +350,15 @@ define [
$scope.archiveOrLeaveSelectedProjects() $scope.archiveOrLeaveSelectedProjects()
$scope.archiveOrLeaveSelectedProjects = () -> $scope.archiveOrLeaveSelectedProjects = () ->
selected_projects = $scope.getSelectedProjects() $scope.archiveOrLeaveProjects($scope.getSelectedProjects())
selected_project_ids = $scope.getSelectedProjectIds()
$scope.archiveOrLeaveProjects = (projects) ->
projectIds = projects.map (p) -> p.id
# Remove project from any tags # Remove project from any tags
for tag in $scope.tags for tag in $scope.tags
$scope._removeProjectIdsFromTagArray(tag, selected_project_ids) $scope._removeProjectIdsFromTagArray(tag, projectIds)
for project in selected_projects for project in projects
project.tags = [] project.tags = []
if project.accessLevel == "owner" if project.accessLevel == "owner"
project.archived = true project.archived = true
@ -414,13 +415,14 @@ define [
$scope.updateVisibleProjects() $scope.updateVisibleProjects()
$scope.restoreSelectedProjects = () -> $scope.restoreSelectedProjects = () ->
selected_projects = $scope.getSelectedProjects() $scope.restoreProjects($scope.getSelectedProjects())
selected_project_ids = $scope.getSelectedProjectIds()
for project in selected_projects $scope.restoreProjects = (projects) ->
projectIds = projects.map (p) -> p.id
for project in projects
project.archived = false project.archived = false
for project_id in selected_project_ids for projectId in projectIds
queuedHttp { queuedHttp {
method: "POST" method: "POST"
url: "/project/#{project_id}/restore" url: "/project/#{project_id}/restore"
@ -437,13 +439,14 @@ define [
) )
$scope.downloadSelectedProjects = () -> $scope.downloadSelectedProjects = () ->
selected_project_ids = $scope.getSelectedProjectIds() $scope.downloadProjectsById($scope.getSelectedProjectIds())
event_tracking.send 'project-list-page-interaction', 'project action', 'Download Zip'
if selected_project_ids.length > 1
path = "/project/download/zip?project_ids=#{selected_project_ids.join(',')}"
else
path = "/project/#{selected_project_ids[0]}/download/zip"
$scope.downloadProjectsById = (projectIds) ->
event_tracking.send 'project-list-page-interaction', 'project action', 'Download Zip'
if projectIds.length > 1
path = "/project/download/zip?project_ids=#{projectIds.join(',')}"
else
path = "/project/#{projectIds[0]}/download/zip"
window.location = path window.location = path
$scope.openV1ImportModal = (project) -> $scope.openV1ImportModal = (project) ->
@ -490,3 +493,19 @@ define [
$scope.$watch "project.selected", (value) -> $scope.$watch "project.selected", (value) ->
if value? if value?
$scope.updateSelectedProjects() $scope.updateSelectedProjects()
$scope.clone = (e) ->
e.stopPropagation()
$scope.cloneProject($scope.project, "#{$scope.project.name} (Copy)")
$scope.download = (e) ->
e.stopPropagation()
$scope.downloadProjectsById([$scope.project.id])
$scope.archive = (e) ->
e.stopPropagation()
$scope.archiveOrLeaveProjects([$scope.project])
$scope.restore = (e) ->
e.stopPropagation()
$scope.restoreProjects([$scope.project])

View file

@ -369,6 +369,16 @@ ul.project-list {
.v1-badge { .v1-badge {
margin-left: -4px; margin-left: -4px;
} }
.action-btn-row-header, .action-btn-row {
padding-right: 20px;
text-align: right;
}
.action-btn {
padding: 0 0.3em;
margin-left: 0.2em;
}
} }
i.tablesort { i.tablesort {
padding-left: 8px; padding-left: 8px;