@kohanajs/mod-cms
Advanced tools
Comparing version 9.0.0 to 9.1.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [9.1.0](https://gitlab.com/kohana-js/proposals/level0/mod-cms/compare/v9.0.0...v9.1.0) (2022-07-26) | ||
### Features | ||
* publish weights ([44c57bb](https://gitlab.com/kohana-js/proposals/level0/mod-cms/commit/44c57bb4d554b57c5413c58e4a87a24e4593111e)) | ||
## [9.0.0](https://gitlab.com/kohana-js/proposals/level0/mod-cms/compare/v8.0.0...v9.0.0) (2022-07-26) | ||
@@ -7,0 +14,0 @@ |
@@ -34,3 +34,2 @@ const path = require('path'); | ||
const items = instances.filter(it => it.page_type === page_type); | ||
@@ -42,3 +41,3 @@ items.forEach(page => { | ||
page.live_weight = livePage.weight; | ||
page.synced = page.weight === livePage.weight && page.original === livePage.original; | ||
page.synced = page.original === livePage.original; | ||
} | ||
@@ -45,0 +44,0 @@ }); |
@@ -27,3 +27,29 @@ const { ControllerAdmin } = require('@kohanajs/mod-admin'); | ||
async publish_weights(){ | ||
const $_POST = this.state.get(ControllerMixinMultipartForm.POST_DATA); | ||
const database = this.state.get(ControllerMixinDatabase.DATABASES).get('live'); | ||
const weightMap = new Map(); | ||
Object.keys($_POST).forEach(key => { | ||
const matches = key.match(/^\((\d+)\):weight$/i); | ||
if(matches === null)return; | ||
weightMap.set(matches[1], $_POST[key]); | ||
}); | ||
const livePages = await ORM.readBy(Page, 'id', [...weightMap.keys()], {database, asArray:true}); | ||
await Promise.all(livePages.map(async page=>{ | ||
const inputWeight = parseInt(weightMap.get(String(page.id))); | ||
if(page.weight === inputWeight)return; | ||
page.weight = inputWeight; | ||
await page.write(); | ||
})); | ||
} | ||
async action_update() { | ||
const $_POST = this.state.get(ControllerMixinMultipartForm.POST_DATA); | ||
if($_POST.action === 'publish_weights')await this.publish_weights() | ||
//if no param id, create page proxy | ||
@@ -33,3 +59,2 @@ const instance = this.state.get('instance'); | ||
const $_POST = this.state.get(ControllerMixinMultipartForm.POST_DATA); | ||
const original = HelperPageText.getOriginal(instance); | ||
@@ -36,0 +61,0 @@ //update original |
{ | ||
"name": "@kohanajs/mod-cms", | ||
"version": "9.0.0", | ||
"version": "9.1.0", | ||
"description": "The CMS module for KohanaJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102068
1349