Skip to content

Commit

Permalink
Feature: precontrib bug update and duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Nov 14, 2016
1 parent 2980fc3 commit 0dcc554
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/cli/cms/operations/duplicate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path'
import extend from 'extend'

import {
abeExtend,
Expand Down Expand Up @@ -26,6 +27,11 @@ const duplicate = function(oldPostUrl, template, newPath, name, req, isUpdate =
revisions = posts[0].revisions
if(revisions != null && revisions[0] != null) {
json = cmsData.file.get(revisions[0].path)

json = extend(true, json, req.body)
console.log('* * * * * * * * * * * * * * * * * * * * * * * * * * * * *')
console.log('json', json)

delete json.abe_meta
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/server/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import express from 'express'
import * as abe from '../../cli'
import {
postCreate
,getDuplicate
,getUpdate
,postDuplicate
,postUpdate
,getListUrl
,getListHooks
,getMain
Expand Down Expand Up @@ -32,8 +32,8 @@ abeExtend.hooks.instance.trigger('afterHandlebarsHelpers', Handlebars)
abeExtend.hooks.instance.trigger('beforeAddRoute', router)

router.post('/abe/create*', postCreate)
router.get('/abe/duplicate*', getDuplicate)
router.get('/abe/update*', getUpdate)
router.post('/abe/duplicate*', postDuplicate)
router.post('/abe/update*', postUpdate)
router.post('/abe/sql-request*', postSqlRequest)
router.post('/abe/page/*', postPage)
router.get('/abe/page/*', getPage)
Expand Down
5 changes: 0 additions & 5 deletions src/server/public/scripts/modules/FormCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ export default class FormCreate {
this._form = document.querySelector('.form-create')

this._formInputs = [].slice.call(this._form.querySelectorAll('input, select'))
// this._formInputs = this._formInputs.concat([].slice.call(this._form.querySelectorAll('select')))

// this._templateName = this._form.querySelector('[data-type-template-abe]')
// this._tplName = this._form.querySelector('[name=tplName]')
this._submitBtn = this._form.querySelector('button[type=submit]')
// this._inputs = [].slice.call(this._form.querySelectorAll('input[type=text]'))
// this._selects = [].slice.call(this._form.querySelectorAll('select[id*="level-"]'))

// // constantes methodes
// this._handlePathChange = this._pathChange.bind(this)
Expand Down
8 changes: 4 additions & 4 deletions src/server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getMain from './get-main'
import postCreate from './post-create'
import getDuplicate from './get-duplicate'
import getUpdate from './get-update'
import postDuplicate from './post-duplicate'
import postUpdate from './post-update'
import getListUrl from './get-list-url'
import getListHooks from './get-list-hooks'
import getPage from './get-page'
Expand All @@ -23,8 +23,8 @@ export {
,postCreate
,getListUrl
,getListHooks
,getDuplicate
,getUpdate
,postDuplicate
,postUpdate
,getPage
,postPage
,postPublish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
var route = function(req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)

var p = cmsOperations.duplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req)
var filepath = req.originalUrl.replace('/abe/duplicate', '')
var folderName = filepath.split('/')
var postName = folderName.pop()
folderName = folderName.join('/')

var p = cmsOperations.duplicate(req.body.oldFilePath, req.body.selectTemplate, folderName, postName, req)

p.then((resSave) => {
var result = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
var route = function(req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)

var p = cmsOperations.duplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req, true)
var filepath = req.originalUrl.replace('/abe/update', '')
var folderName = filepath.split('/')
var postName = folderName.pop()
folderName = folderName.join('/')

var p = cmsOperations.duplicate(req.body.oldFilePath, req.body.selectTemplate, folderName, postName, req, true)

p.then((resSave) => {
var result = {
Expand Down
4 changes: 2 additions & 2 deletions src/server/views/partials/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ <h1>
</div>
</div>

<input class="form-control" type="hidden" name="filePath" id="filePath" value="{{@root.folderPath}}" />
<input class="form-control" type="hidden" name="oldFilePath" id="oldFilePath" value="{{json.abe_meta.link}}" />
<input class="form-control" type="hidden" name="filePath" data-id="filePath" id="filePath" value="{{@root.folderPath}}" />
<input class="form-control" type="hidden" name="oldFilePath" data-id="oldFilePath" id="oldFilePath" value="{{json.abe_meta.link}}" />

</form>
</div>
Expand Down

0 comments on commit 0dcc554

Please sign in to comment.