-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix drag and drop #1094
Fix drag and drop #1094
Changes from all commits
2d7f3e9
ca08776
7a95a3a
21fe774
246c2c9
cc03f48
243cb3f
3c3d308
db9edfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
<style lang="less"> | ||
@import '~less/admin/variables'; | ||
|
||
.resource-upload-dropzone { | ||
border: 4px dashed #bbb; | ||
border: 4px dashed @gray-lte; | ||
min-height: 150px; | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
|
||
.lead { | ||
margin-bottom: 0; | ||
} | ||
|
||
.drop-active > & { | ||
border: 4px dashed @green; | ||
} | ||
} | ||
</style> | ||
|
||
|
@@ -22,7 +28,7 @@ | |
</span> | ||
<div class="info-box-content"> | ||
<span class="info-box-text">{{file.name}}</span> | ||
<span class="info-box-number">{{file.filesize | filesize}}</span> | ||
<span class="info-box-number">{{file.size | filesize}}</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am pretty sure a linter would have caught this issue — @noirbizarre @vinyll do you know of anything to enforce data models for Vue.js? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that a linter can find that a variable name is removed from the spec on a non-typed variable. File(s) in this component (is)are provided by |
||
<div class="progress"> | ||
<div class="progress-bar" :style="{width: progress+'%'}"></div> | ||
</div> | ||
|
@@ -124,22 +130,19 @@ export default { | |
upload_endpoint() { | ||
const operations = API.datasets.operations; | ||
let params = {}; | ||
let endpoint = 'upload_'; | ||
if (typeof this.dataset !== 'undefined') { | ||
params = {dataset: this.dataset.id}; | ||
} | ||
if (this.is_community) { | ||
endpoint += 'community_'; | ||
params.community = this.resource.id; | ||
} else { | ||
endpoint += 'dataset_'; | ||
} | ||
if (this.resource.id) { | ||
endpoint += 'resource'; | ||
params.rid = this.resource.id; | ||
} else { | ||
endpoint += 'resources'; | ||
if (this.is_community) { | ||
params.community = this.resource.id; | ||
} else { | ||
params.rid = this.resource.id; | ||
} | ||
} | ||
const route_new = this.resource.id ? '' : 'new_'; | ||
const route_namespace = this.is_community ? 'community_' : 'dataset_'; | ||
const endpoint = `upload_${route_new}${route_namespace}resource`; | ||
return operations[endpoint].urlify(params); | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
td .progress { | ||
margin-top: 5px; | ||
} | ||
} | ||
|
||
.drop-active > & { | ||
|
@@ -53,13 +57,15 @@ | |
<td v-if="reordering"></td> | ||
<td> | ||
<div class="ellipsis">{{ file.name }}</div> | ||
</td> | ||
<td>{{ file.name | fileext }}</td> | ||
<td>{{ file.size | filesize }}</td> | ||
<td colspan="2"> | ||
<div class="progress progress-xs progress-striped active"> | ||
<div class="progress-bar progress-bar-primary" | ||
id="progress-{{file.id}}" style="width: 0%"></div> | ||
<div class="progress-bar progress-bar-primary" | ||
id="progress-{{file.id}}" style="width: 0%"></div> | ||
</div> | ||
</td> | ||
<td>{{ file.type }}</td> | ||
<td>{{ file.size | filesize }}</td> | ||
</tr> | ||
<tr v-for="resource in dataset.resources" @click="display(resource)" | ||
:class="{ 'pointer': !reodering, 'move': reordering }" | ||
|
@@ -155,13 +161,17 @@ export default { | |
}, | ||
events: { | ||
'uploader:progress': function(id, uploaded, total) { | ||
const el = this.$el.getElementById(`progress-${id}`); | ||
const el = document.getElementById(`progress-${id}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we breaking the rules of the Vue component? Right now it seems we are looking for something outside of the component itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we are looking for a component inside (defined in the associated template). Sadly, |
||
el.style.width = `${Math.round(uploaded * 100 / total)}%`; | ||
}, | ||
'uploader:complete': function(id, response) { | ||
const file = this.$uploader.getFile(id); | ||
this.files.$remove(this.files.indexOf(file)); | ||
'uploader:complete': function(id, response, file) { | ||
this.files.$remove(file); | ||
this.dataset.resources.unshift(response); | ||
}, | ||
'uploader:error': function(id) { | ||
// Remove the progressing file (an error is already displayed globally) | ||
const file = this.$uploader.getFile(id); | ||
this.files.splice(this.files.indexOf(file), 1); | ||
} | ||
}, | ||
ready() { | ||
|
@@ -210,7 +220,7 @@ export default { | |
watch: { | ||
'dataset.id': function(id) { | ||
if (id) { | ||
this.upload_endpoint = API.datasets.operations.upload_dataset_resource.urlify({dataset: id}); | ||
this.upload_endpoint = API.datasets.operations.upload_new_dataset_resource.urlify({dataset: id}); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noirbizarre I can see you hooked on the variables thingy 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I always had, but there was no proper
@import ~
support in vue-loader initially so it was not possible to properly use them.When I encounter a case were I can use them, I try to do/fix it