Commit fe5d2c55 authored by Jacob Schatz's avatar Jacob Schatz

Discard changes to files when cancel edit is hit.

parent 77ab714a
...@@ -37,7 +37,6 @@ function addEventsForNonVueEls() { ...@@ -37,7 +37,6 @@ function addEventsForNonVueEls() {
window.onbeforeunload = function (e) { window.onbeforeunload = function (e) {
const hasChanged = Store.openedFiles const hasChanged = Store.openedFiles
.some(file => file.changed); .some(file => file.changed);
console.log('hasChanged',hasChanged)
if(!hasChanged) return; if(!hasChanged) return;
e = e || window.event; e = e || window.event;
if (e) { if (e) {
......
...@@ -30,17 +30,6 @@ export default class RepoEditButton { ...@@ -30,17 +30,6 @@ export default class RepoEditButton {
this.editMode = !this.editMode; this.editMode = !this.editMode;
}, },
}, },
watch: {
dialog: {
handler(obj) {
if(obj.status) {
obj.status = false;
}
},
deep: true,
}
}
}); });
} }
} }
...@@ -86,6 +86,23 @@ const RepoEditor = { ...@@ -86,6 +86,23 @@ const RepoEditor = {
this.showHide(); this.showHide();
}, },
dialog: {
handler(obj) {
if(obj.status) {
obj.status = false;
this.openedFiles.map((f) => {
if(f.active) {
this.blobRaw = f.plain;
}
f.changed = false;
delete f.newContent;
});
this.editMode = false;
}
},
deep: true,
},
isTree() { isTree() {
this.showHide(); this.showHide();
}, },
......
...@@ -97,7 +97,7 @@ const RepoStore = { ...@@ -97,7 +97,7 @@ const RepoStore = {
RepoStore.blobRaw = file.base64; RepoStore.blobRaw = file.base64;
RepoStore.binaryMimeType = file.mime_type; RepoStore.binaryMimeType = file.mime_type;
} else { } else {
RepoStore.blobRaw = file.plain; RepoStore.blobRaw = file.newContent || file.plain;
} }
if (!file.loading) RepoHelper.toURL(file.url, file.name); if (!file.loading) RepoHelper.toURL(file.url, file.name);
......
...@@ -24,7 +24,7 @@ const RepoTab = { ...@@ -24,7 +24,7 @@ const RepoTab = {
xClicked(file) { xClicked(file) {
if (file.changed) return; if (file.changed) return;
RepoStore.removeFromOpenedFiles(file); this.$emit('xclicked', file);
}, },
}, },
}; };
......
...@@ -17,6 +17,10 @@ const RepoTabs = { ...@@ -17,6 +17,10 @@ const RepoTabs = {
isOverflow() { isOverflow() {
return this.$el.scrollWidth > this.$el.offsetWidth; return this.$el.scrollWidth > this.$el.offsetWidth;
}, },
xclicked(file) {
Store.removeFromOpenedFiles(file);
}
}, },
watch: { watch: {
...@@ -33,6 +37,6 @@ export default RepoTabs; ...@@ -33,6 +37,6 @@ export default RepoTabs;
<template> <template>
<ul id="tabs" v-if="isMini" v-cloak :class="{'overflown': tabsOverflow}"> <ul id="tabs" v-if="isMini" v-cloak :class="{'overflown': tabsOverflow}">
<repo-tab v-for="tab in openedFiles" :key="tab.id" :tab="tab" :class="{'active' : tab.active}"/> <repo-tab v-for="tab in openedFiles" :key="tab.id" :tab="tab" :class="{'active' : tab.active}" @xclicked="xclicked"/>
</ul> </ul>
</template> </template>
...@@ -97,6 +97,15 @@ ...@@ -97,6 +97,15 @@
white-space: nowrap; white-space: nowrap;
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
&.remove {
animation: swipeRightDissapear ease-in 0.1s;
animation-iteration-count: 1;
transform-origin: 0% 50%;
a {
width: 0;
}
}
&.active { &.active {
background: $white-light; background: $white-light;
} }
...@@ -372,11 +381,17 @@ ...@@ -372,11 +381,17 @@
transform: scaleX(0.00); transform: scaleX(0.00);
} }
45% { 100% {
transform: scaleX(0.26); transform: scaleX(1.00);
}
}
@keyframes swipeRightDissapear {
0% {
transform: scaleX(1.00);
} }
100% { 100% {
transform: scaleX(1.00); transform: scaleX(0.00);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment