Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions modules/collections/client/scss/collections.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
.collection-document-table {
td {
vertical-align: top !important;
cursor: pointer;
}

.no-results td {
cursor: auto;
}

.date-col {
Expand Down Expand Up @@ -73,13 +78,13 @@
.date {
flex: 0 1 10%;
}

.name {
flex: 1 1 20%;
}

.status {
flex: 0 1 8%;
flex: 0 1 8%;
}
}

Expand All @@ -88,13 +93,13 @@
.date {
flex: 0 1 15rem;
}

.name {
flex: 1 1 20rem;
flex: 1 1 20rem;
}

.status {
flex: 0 1 15rem;
}
}
}
}
16 changes: 8 additions & 8 deletions modules/collections/client/views/collection-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ <h1>{{ collection.displayName }}</h1>
<button class="btn btn-default btn-sm" ui-sref="p.collection.list">
Cancel
</button>
<button class="btn btn-default btn-sm"
<button class="btn btn-default btn-sm"
ng-if="collection.addedBy && !collection.isPublished" ng-click="publish()" type="button">
<span class="glyphicon glyphicon-ok-circle"></span><span>Publish</span>
</button>
<button class="btn btn-default btn-sm"
<button class="btn btn-default btn-sm"
ng-if="collection.addedBy && collection.isPublished" ng-click="unpublish()" type="button">
<span class="glyphicon glyphicon-ban-circle"></span><span>Unpublish</span>
</button>
<button class="btn btn-default btn-sm" ui-sref="p.collection.edit({ collectionId:collection._id })" type="button">
Edit
</button>
<button class="btn btn-default btn-sm"
<button class="btn btn-default btn-sm"
ng-if="collection.addedBy" ng-click="delete()" type="button">
<span class="glyphicon glyphicon-trash"></span><span>Delete</span>
</button>
</div>
</div>

<div class="view-body-container">
<section>
<div class="row">
Expand Down Expand Up @@ -85,7 +85,7 @@ <h2>Main Document</h2>
</div>
<div class="table-container collection-docs">
<table class="table collection-document-table" ng-table="mainTableParams">
<tr ng-repeat="d in $data">
<tr ng-repeat="d in $data" ng-click="goToDocument(d.document)">
<td header-class="'name-col'" data-title="'Name'">{{ d.document.displayName | removeExtension }}</td>
<td header-class="'date-col'" data-title="'Document Date'">{{ d.document.documentDate | amDateFormat:'YYYY-MM-DD' }}</td>
<td header-class="'date-uploaded-col'" data-title="'Date Uploaded'">{{ d.document.dateUploaded | amDateFormat:'YYYY-MM-DD' }}</td>
Expand Down Expand Up @@ -121,15 +121,15 @@ <h2>Other Documents</h2>
</button>
<button class="btn btn-default btn-sm"
title="Set the default order documents will be displayed"
x-reorder-collection-modal x-collection="collection"
x-reorder-collection-modal x-collection="collection"
x-on-save="otherDocsReordered">
<span class="glyphicon glyphicon-sort"></span>
<span>Set Document Order</span>
</button>
</div>
<div class="table-container collection-docs">
<table class="table collection-document-table" ng-table="otherTableParams">
<tr ng-repeat="d in $data">
<tr ng-repeat="d in $data" ng-click="goToDocument(d.document)">
<td header-class="'name-col'" data-title="'Name'" sortable="'Name'">{{ d.document.displayName | removeExtension }}</td>
<td header-class="'date-col'" data-title="'Document Date'" sortable="'Document Date'">{{ d.document.documentDate | amDateFormat:'YYYY-MM-DD' }}</td>
<td header-class="'date-uploaded-col'" data-title="'Date Uploaded'" sortable="'Uploaded'">{{ d.document.dateUploaded | amDateFormat:'YYYY-MM-DD' }}</td>
Expand All @@ -153,4 +153,4 @@ <h2>Other Documents</h2>
</div>
</section>

</div>
</div>
43 changes: 23 additions & 20 deletions scripts/collections/update-inspections.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ var getInspections = function(db) {
});
};

var updateInspectionName = function(db, inspection, name) {
return new Promise(function(resolve, reject) {
db.collection('collections').updateOne({ _id: inspection._id }, { $set: { displayName: name } } , {}, function(err, obj) {
if (err) {
console.log('x failed to update inspection ' + inspection.displayName + ' to ' + name);
} else if (obj.result.n === 0) {
console.log('x failed to find inspection ' + inspection.displayName);
} else {
console.log(': ' + inspection.displayName + ' -> ' + name);
}
resolve();
});
});
};

var scanInspection = function(db, inspection) {
return new Promise(function(resolve, reject) {
// Find the collection document for the main document
Expand Down Expand Up @@ -86,23 +71,38 @@ var scanInspection = function(db, inspection) {
} else {
var name = '';
if (inspection.isForMEM) {
// Find the last document category
// Find the last document sub-category
var category = _.last(document.documentCategories);
if (category) {
category = _.last(_.split(category, ' > '));
}
name = category + ' Inspection ' + match[0];
if (category === 'Inspection Report') {
// Ignore if there's no sub-category
name = 'Inspection ' + match[0];
} else {
name = category + ' Inspection ' + match[0];
}
} else if (inspection.isForENV) {
var name = 'Inspection ' + match[0];
// No sub-categories
name = 'Inspection ' + match[0];
}
if (name) {
if (noUpdate) {
console.log(': ' + inspection.displayName + ' -> ' + name);
resolve();
} else {
updateInspectionName(db, inspection, name);
db.collection('collections').updateOne({ _id: inspection._id }, { $set: { displayName: name } } , {}, function(err, obj) {
if (err) {
console.log('x failed to update inspection ' + inspection.displayName + ' to ' + name);
} else if (obj.result.n === 0) {
console.log('x failed to find inspection ' + inspection.displayName);
} else {
console.log(': ' + inspection.displayName + ' -> ' + name);
}
resolve();
});
}
}
resolve();
}
}
});
Expand All @@ -116,6 +116,9 @@ var run = function () {
var database = null;
return new Promise(function (resolve, reject) {
console.log('start');
if (noUpdate) {
console.log(': NO UPDATE');
}
MongoClient.connect(url)
.then(function(db) {
console.log(': db connected');
Expand Down