mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:54:50 +08:00
UX: Switched composer draft saving to animations (#7356)
This commit is contained in:
@ -14,7 +14,6 @@ export default Ember.Component.extend({
|
|||||||
// page which is wrong.
|
// page which is wrong.
|
||||||
emailOrUsername: null,
|
emailOrUsername: null,
|
||||||
hasCustomMessage: false,
|
hasCustomMessage: false,
|
||||||
hasCustomMessage: false,
|
|
||||||
customMessage: null,
|
customMessage: null,
|
||||||
inviteIcon: "envelope",
|
inviteIcon: "envelope",
|
||||||
invitingExistingUserToTopic: false,
|
invitingExistingUserToTopic: false,
|
||||||
|
@ -74,6 +74,8 @@ const Composer = RestModel.extend({
|
|||||||
_categoryId: null,
|
_categoryId: null,
|
||||||
unlistTopic: false,
|
unlistTopic: false,
|
||||||
noBump: false,
|
noBump: false,
|
||||||
|
draftSaving: false,
|
||||||
|
draftSaved: false,
|
||||||
|
|
||||||
archetypes: function() {
|
archetypes: function() {
|
||||||
return this.site.get("archetypes");
|
return this.site.get("archetypes");
|
||||||
@ -971,7 +973,8 @@ const Composer = RestModel.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
draftStatus: I18n.t("composer.saving_draft_tip"),
|
draftSaved: false,
|
||||||
|
draftSaving: true,
|
||||||
draftConflictUser: null
|
draftConflictUser: null
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1004,18 +1007,21 @@ const Composer = RestModel.extend({
|
|||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.conflict_user) {
|
if (result.conflict_user) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
|
draftSaving: false,
|
||||||
draftStatus: I18n.t("composer.edit_conflict"),
|
draftStatus: I18n.t("composer.edit_conflict"),
|
||||||
draftConflictUser: result.conflict_user
|
draftConflictUser: result.conflict_user
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
draftStatus: I18n.t("composer.saved_draft_tip"),
|
draftSaving: false,
|
||||||
|
draftSaved: true,
|
||||||
draftConflictUser: null
|
draftConflictUser: null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
|
draftSaving: false,
|
||||||
draftStatus: I18n.t("composer.drafts_offline"),
|
draftStatus: I18n.t("composer.drafts_offline"),
|
||||||
draftConflictUser: null
|
draftConflictUser: null
|
||||||
});
|
});
|
||||||
@ -1033,6 +1039,8 @@ const Composer = RestModel.extend({
|
|||||||
self.set("draftStatus", null);
|
self.set("draftStatus", null);
|
||||||
self.set("draftConflictUser", null);
|
self.set("draftConflictUser", null);
|
||||||
self._clearingStatus = null;
|
self._clearingStatus = null;
|
||||||
|
self.set("draftSaving", false);
|
||||||
|
self.set("draftSaved", false);
|
||||||
},
|
},
|
||||||
Ember.Test ? 0 : 1000
|
Ember.Test ? 0 : 1000
|
||||||
);
|
);
|
||||||
|
@ -162,6 +162,8 @@
|
|||||||
{{#if model.draftConflictUser}}
|
{{#if model.draftConflictUser}}
|
||||||
{{avatar model.draftConflictUser imageSize="small"}}
|
{{avatar model.draftConflictUser imageSize="small"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if model.draftSaving}}<div class="spinner small"></div>{{/if}}
|
||||||
|
{{#if model.draftSaved}}{{d-icon 'check' class='save-animation'}}{{/if}}
|
||||||
{{model.draftStatus}}
|
{{model.draftStatus}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -453,3 +453,52 @@ div.ac-wrap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.save-animation {
|
||||||
|
transition: all 1s ease-in-out;
|
||||||
|
-webkit-transform: scale(0.1);
|
||||||
|
transform: scale(0.1);
|
||||||
|
-webkit-animation: transformer 1.5s forwards;
|
||||||
|
animation: transformer 1.5s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes transformer {
|
||||||
|
0% {
|
||||||
|
-webkit-transform: scale(0.1);
|
||||||
|
}
|
||||||
|
20% {
|
||||||
|
-webkit-transform: scale(1.2);
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
-webkit-transform: scale(1);
|
||||||
|
-webkit-filter: opacity(1);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
-webkit-transform: scale(1);
|
||||||
|
-webkit-filter: opacity(1);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
-webkit-transform: scale(1);
|
||||||
|
-webkit-filter: opacity(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes transformer {
|
||||||
|
0% {
|
||||||
|
transform: scale(0.1);
|
||||||
|
}
|
||||||
|
20% {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1497,8 +1497,6 @@ en:
|
|||||||
toggle_whisper: "Toggle Whisper"
|
toggle_whisper: "Toggle Whisper"
|
||||||
toggle_unlisted: "Toggle Unlisted"
|
toggle_unlisted: "Toggle Unlisted"
|
||||||
posting_not_on_topic: "Which topic do you want to reply to?"
|
posting_not_on_topic: "Which topic do you want to reply to?"
|
||||||
saving_draft_tip: "saving..."
|
|
||||||
saved_draft_tip: "saved"
|
|
||||||
saved_local_draft_tip: "saved locally"
|
saved_local_draft_tip: "saved locally"
|
||||||
similar_topics: "Your topic is similar to..."
|
similar_topics: "Your topic is similar to..."
|
||||||
drafts_offline: "drafts offline"
|
drafts_offline: "drafts offline"
|
||||||
|
@ -638,6 +638,8 @@ QUnit.test("Can switch states without abandon popup", async assert => {
|
|||||||
"mode should have changed"
|
"mode should have changed"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.ok(find(".save-animation"), "save animation should show");
|
||||||
|
|
||||||
toggleCheckDraftPopup(false);
|
toggleCheckDraftPopup(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user