summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/static_site_editor/store/mutations.js
blob: 4727d04439c3ede1d6c9d6ac522afb0600a37226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as types from './mutation_types';

export default {
  [types.LOAD_CONTENT](state) {
    state.isLoadingContent = true;
  },
  [types.RECEIVE_CONTENT_SUCCESS](state, { title, content }) {
    state.isLoadingContent = false;
    state.isContentLoaded = true;
    state.title = title;
    state.content = content;
    state.originalContent = content;
  },
  [types.RECEIVE_CONTENT_ERROR](state) {
    state.isLoadingContent = false;
  },
  [types.SET_CONTENT](state, content) {
    state.content = content;
  },
  [types.SUBMIT_CHANGES](state) {
    state.isSavingChanges = true;
  },
  [types.SUBMIT_CHANGES_SUCCESS](state, meta) {
    state.savedContentMeta = meta;
    state.isSavingChanges = false;
    state.originalContent = state.content;
  },
  [types.SUBMIT_CHANGES_ERROR](state) {
    state.isSavingChanges = false;
  },
};