Skip to content

Commit 4bfbc4b

Browse files
committed
fix for case where StreamField not one by page
1 parent 5693014 commit 4bfbc4b

6 files changed

Lines changed: 21 additions & 24 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Django StreamField
22

33
This is a simple realisation of StreamField's idea of Wagtail CMS for plain Django admin or with Grappelli skin.
4-
Stable version: 2.0.6
4+
Stable version: 2.0.7
55

66
[Major changes (1.4.5 > 2)](changes2.0.md)
77

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "streamfield_widget.js",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "",
55
"private": true,
66
"scripts": {

frontend/src/components/App.vue

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
import StreamBlock from '@/components/StreamBlock.vue'
55
import AbstractBlock from '@/components/AbstractBlock.vue'
66
7-
let
8-
text_area,
9-
delete_blocks_from_db,
10-
popup_size;
11-
127
function id_to_windowname(text) {
138
text = text.replace(/\./g, '__dot__');
149
text = text.replace(/\-/g, '__dash__');
@@ -31,26 +26,29 @@
3126
stream: [], // [{model_name: ..., id: ...}, ...]
3227
model_info: {}, // {'model_name': model.__doc__},
3328
base_admin_url: "",
34-
stream_texts: window.stream_texts
29+
stream_texts: window.stream_texts,
30+
text_area: null,
31+
delete_blocks_from_db: null,
32+
popup_size: null
3533
}
3634
},
3735
beforeMount: function() {
38-
text_area = this.app_node.querySelector('textarea')
39-
delete_blocks_from_db = Boolean(text_area.hasAttribute('delete_blocks_from_db'))
40-
popup_size = text_area.dataset.popup_size ? JSON.parse(text_area.dataset.popup_size) : [1000, 500]
36+
this.text_area = this.app_node.querySelector('textarea')
37+
this.delete_blocks_from_db = Boolean(this.text_area.hasAttribute('delete_blocks_from_db'))
38+
this.popup_size = this.text_area.dataset.popup_size ? JSON.parse(this.text_area.dataset.popup_size) : [1000, 500]
4139
42-
this.base_admin_url = text_area.getAttribute('base_admin_url')
43-
this.stream = JSON.parse(text_area.innerHTML)
44-
this.model_info = JSON.parse(text_area.getAttribute('model_list_info'))
40+
this.base_admin_url = this.text_area.getAttribute('base_admin_url')
41+
this.stream = JSON.parse(this.text_area.innerHTML)
42+
this.model_info = JSON.parse(this.text_area.getAttribute('model_list_info'))
4543
4644
if (this.stream.length && !this.stream[0].hasOwnProperty('collapsed')) {
4745
this.setAllCollapsed(false)
4846
}
4947
5048
// delete removed instances from db when form submit
51-
if ( delete_blocks_from_db ) {
49+
if ( this.delete_blocks_from_db ) {
5250
let app = this
53-
django.jQuery('input[type="submit"]', text_area.closest('form')).on('click', function(e){
51+
django.jQuery('input[type="submit"]', this.text_area.closest('form')).on('click', function(e){
5452
if ( !app.will_removed.length ) return;
5553
5654
e.preventDefault();
@@ -80,7 +78,6 @@
8078
8179
}); // EventListener
8280
}
83-
8481
},
8582
methods: {
8683
isAbstract: function(block) {
@@ -173,15 +170,15 @@
173170
let triggeringLink = e.target;
174171
let name = id_to_windowname(triggeringLink.id.replace(/^(change|add|delete)_/, ''));
175172
let href = triggeringLink.href;
176-
let win = window.open(href, name, 'height=' + popup_size[1] + ',width=' + popup_size[0] + ',resizable=yes,scrollbars=yes');
173+
let win = window.open(href, name, 'height=' + this.popup_size[1] + ',width=' + this.popup_size[0] + ',resizable=yes,scrollbars=yes');
177174
win.focus();
178175
return false;
179176
}
180177
},
181178
watch: {
182179
stream: {
183180
handler(nv) {
184-
text_area.innerHTML = JSON.stringify(nv.map(function(i){
181+
this.text_area.innerHTML = JSON.stringify(nv.map(function(i){
185182
// return only fields that in initial data
186183
return {
187184
unique_id: i.unique_id,
@@ -190,7 +187,7 @@
190187
options: i.options,
191188
collapsed: i.collapsed
192189
};
193-
}));
190+
}));
194191
},
195192
deep: true
196193
}
@@ -210,7 +207,7 @@
210207
</div>
211208

212209
<div class="streamfield-models">
213-
<draggable v-model="stream" group="stream" handle=".block-move" item-key="unique_id">
210+
<draggable v-model="stream" :group="app_node.id" handle=".block-move" item-key="unique_id">
214211
<template #item="{element: block}">
215212
<StreamBlock v-if="!isAbstract(block)" :block="block" :ref="block.unique_id"/>
216213
<AbstractBlock v-else :block="block" :ref="block.unique_id" />

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="django-streamfield",
8-
version="2.0.6",
8+
version="2.0.7",
99
author="Yury Lapshinov",
1010
author_email="y.raagin@gmail.com",
1111
description="StreamField for native Django Admin or with Grappelli",

streamfield/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name = "streamfield"
2-
VERSION = "2.0.6"
2+
VERSION = "2.0.7"

streamfield/static/streamfield/streamfield_widget.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)