Skip to content

Commit

Permalink
Fix a re-order issue, and some ownership things on images
Browse files Browse the repository at this point in the history
  • Loading branch information
simonv3 committed Apr 23, 2016
1 parent f0e02a6 commit 6fa6e9f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1458759122
1460677669
4 changes: 2 additions & 2 deletions .sandstorm/sandstorm-pkgdef.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const pkgdef :Spk.PackageDefinition = (

appTitle = (defaultText = "Annotate"),

appVersion = 5, # Increment this for every release.
appVersion = 6, # Increment this for every release.

appMarketingVersion = (defaultText = "1.2.1"),
appMarketingVersion = (defaultText = "1.3.0"),
# Human-readable representation of appVersion. Should match the way you
# identify versions of your app in documentation and marketing.

Expand Down
33 changes: 25 additions & 8 deletions client/directives/anDropbox.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,41 @@ angular.module('annotate').directive('anDropbox',
{'sort': {'uploadedAt': -1}}
).fetch()

// Let's also check what the most recent
// highest ordering is, and add it to the end.

var highestOrder = Images.find(
{},
{'sort': {'metadata.order': -1}}
).fetch()[0].metadata.order

Images.insert(file, function(err, newFile) {
if (err) console.log('error insterting image', err);

let updateSetForNewFile = {
'metadata.owner': Meteor.user(),
'metadata.order': highestOrder + 1
}

if (existingImages.length > 0) {
existingImages.forEach(function(img) {
Images.update({_id: img._id},
{$set: {'metadata.newest': newFile._id}})
Images.update({_id: img._id},
{$set: {'metadata.newest': newFile._id}})
})

Images.update({_id: existingImages[0]._id},
{$set: {'metadata.next': newFile._id}})
Images.update({_id: newFile._id},
{$set: {
'metadata.previous': existingImages[0]._id,
'metadata.description': existingImages[0].metadata.description,
'metadata.order': existingImages[0].metadata.order
}})

updateSetForNewFile['metadata.previous'] = existingImages[0]._id
if (existingImages[0].metadata) {
updateSetForNewFile['metadata.description'] = existingImages[0].metadata.description
updateSetForNewFile['metadata.order'] = existingImages[0].metadata.order
}
}

Images.update({_id: newFile._id},
{$set: updateSetForNewFile})

$scope.$apply(function() {
$timeout(function() {
$scope.onImageAdded();
Expand Down
7 changes: 5 additions & 2 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@

<header>
<div class="image-meta">
{{ image.metadata.order + 1 }}.
<span class="order" ng-if="image.metadata.order !== undefined">
{{ image.metadata.order + 1 }}.
</span>
<span href="#"
editable-text="image.metadata.description"
e-form="descriptionEditForm"
Expand All @@ -95,7 +97,8 @@
></div>
<footer>
<span class="has-older" ng-show="image.metadata.previous">Has an older version.</span>
<span class="uploaded-by">Uploaded by <span ng-bind="user.services.sandstorm.preferredHandle">.</span>
<span class="uploaded-by" ng-if="image.metadata.owner !== undefined">Uploaded by <span ng-bind="image.metadata.owner.services.sandstorm.preferredHandle">.</span></span>
<div style="clear:both;"></div>
</footer>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions client/styles/components/image-container.import.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.images-container-title.double .image-container {
width: 40%;
width: 44%;
display: inline-block;
margin: 1rem 5%;
margin: 1rem 3%;
}

.image-container {
Expand Down
6 changes: 6 additions & 0 deletions meta/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.3.0

* Adding a file that already exists will replace the existing file, and references to the previous file will be stored. (Files are not deleted).
* We now ask for confirmation before adding an annotation.
* You can now view images in one or two columns.

# 1.2.0

* Annotations now maintain an order and don't change order. They're unique in the entire grain too.
Expand Down

0 comments on commit 6fa6e9f

Please sign in to comment.