Sha256: da94aeaaec4751ba0c69f198ff8f3afe075af2b3230acf786838628b6a6f0c97

Contents?: true

Size: 1.75 KB

Versions: 20

Compression:

Stored size: 1.75 KB

Contents

export default (services) => ({
  fetchSectionBlock({ commit, state: { sections, sectionBlocks } }, id) {
    const sectionBlock = sectionBlocks[id]
    if (sectionBlock) {
      const section = Object.values(sections).find(
        (section) => (section.blocks || []).indexOf(sectionBlock?.id) !== -1,
      )
      commit('SET_SECTION', section) // NOTE: order is important here
      commit('SET_SECTION_BLOCK', sectionBlock)
    }
    return sectionBlock
  },
  addSectionBlock(
    { commit, getters, state: { section, sectionDefinition } },
    { blockType, parentId },
  ) {
    const sectionBlock = services.section.buildDefaultBlock(
      blockType,
      sectionDefinition,
    )
    if (parentId) sectionBlock.parentId = parentId
    commit('ADD_SECTION_BLOCK', sectionBlock)
    commit('TOUCH_SECTION', section.id)
    services.livePreview.addBlock(
      getters.content,
      getters.denormalizedSection,
      sectionBlock,
    )
  },
  removeSectionBlock({ commit, getters, state: { section } }, id) {
    commit('REMOVE_SECTION_BLOCK', id)
    commit('TOUCH_SECTION', section.id)
    services.livePreview.removeBlock(
      getters.content,
      getters.denormalizedSection,
      id,
    )
  },
  sortSectionBlocks({ commit, getters, state: { section } }, change) {
    commit('SORT_SECTION_BLOCKS', change)
    commit('TOUCH_SECTION', section.id)
    services.livePreview.moveBlock(getters.content, getters.denormalizedSection)
  },
  updateSectionBlockContent(
    { commit, getters, state: { section, sectionBlock } },
    change,
  ) {
    commit('UPDATE_SECTION_BLOCK_CONTENT', change)
    commit('TOUCH_SECTION', section.id)
    services.livePreview.updateBlock(
      getters.content,
      getters.denormalizedSection,
      sectionBlock,
      change,
    )
  },
})

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/frontend/editor/store/actions/section-block.js
maglevcms-1.7.2 app/frontend/editor/store/actions/section-block.js
maglevcms-1.7.1 app/frontend/editor/store/actions/section-block.js
maglevcms-1.7.0 app/frontend/editor/store/actions/section-block.js
maglevcms-1.6.1 app/frontend/editor/store/actions/section-block.js
maglevcms-1.6.0 app/frontend/editor/store/actions/section-block.js
maglevcms-1.5.1 app/frontend/editor/store/actions/section-block.js
maglevcms-1.4.0 app/frontend/editor/store/actions/section-block.js
maglevcms-1.3.0 app/frontend/editor/store/actions/section-block.js
maglevcms-1.2.2 app/frontend/editor/store/actions/section-block.js
maglevcms-1.2.1 app/frontend/editor/store/actions/section-block.js
maglevcms-1.2.0 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.7 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.6 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.5 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.4 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.3 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.2 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.1 app/frontend/editor/store/actions/section-block.js
maglevcms-1.1.0 app/frontend/editor/store/actions/section-block.js