mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Фикс сортировки блогов при редактировани топика #587
This commit is contained in:
parent
d52c611852
commit
557aa54258
|
@ -154,6 +154,9 @@ class ModuleTopic_EntityTopic extends Entity
|
|||
*/
|
||||
public function ValidateBlogs($sValue, $aParams)
|
||||
{
|
||||
if (is_string($sValue)) {
|
||||
$sValue = explode(',', $sValue);
|
||||
}
|
||||
if (!$sValue or !is_array($sValue)) {
|
||||
if ($oBlog = $this->Blog_GetPersonalBlogByUserId($this->getUserId())) {
|
||||
$this->setBlogs(array($oBlog));
|
||||
|
@ -601,7 +604,7 @@ class ModuleTopic_EntityTopic extends Entity
|
|||
$aResult = array();
|
||||
if ($aBlogs = $this->getBlogs()) {
|
||||
foreach ($aBlogs as $oBlog) {
|
||||
$aResult[] = $oBlog->getId();
|
||||
$aResult[] = (int)$oBlog->getId();
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
},
|
||||
|
||||
// Ajax параметры
|
||||
params: {}
|
||||
params: {},
|
||||
|
||||
callbacks: {
|
||||
beforeSubmit: null
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -54,6 +58,9 @@
|
|||
submit: function( params ) {
|
||||
$.extend( this.option( 'params' ), params || {} );
|
||||
|
||||
this.option( 'callbacks' )['beforeSubmit'].call(this);
|
||||
|
||||
|
||||
this._submit( this.action, this.element, function( response ) {
|
||||
if ( response.sUrlRedirect ) {
|
||||
window.location.href = response.sUrlRedirect;
|
||||
|
|
|
@ -67,6 +67,11 @@
|
|||
urls: {
|
||||
add: this.option( 'urls.add' ),
|
||||
edit: this.option( 'urls.edit' )
|
||||
},
|
||||
callbacks: {
|
||||
beforeSubmit: function() {
|
||||
_this.prepareParams(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -76,6 +81,12 @@
|
|||
width: '100%'
|
||||
});
|
||||
|
||||
// Установка правильной сортировки блогов
|
||||
var chosenOrder = this.elements.blogs.data('chosenOrder');
|
||||
if (chosenOrder && chosenOrder.length) {
|
||||
this.elements.blogs.setSelectionOrder(chosenOrder);
|
||||
}
|
||||
|
||||
// Превью (изображение)
|
||||
this.elements.image_preview.lsFieldImageAjax({
|
||||
urls: {
|
||||
|
@ -123,6 +134,21 @@
|
|||
previewHide: function() {
|
||||
this.elements.preview.hide();
|
||||
this.elements.preview_content.empty();
|
||||
},
|
||||
|
||||
/**
|
||||
* Дополнительная обработка параметров перед отправкой формы
|
||||
* @param formContent
|
||||
*/
|
||||
prepareParams: function(formContent) {
|
||||
/**
|
||||
* Корректируем сортировку выбранных блогов
|
||||
*/
|
||||
if (this.elements.blogs.length) {
|
||||
formContent.option('params', {
|
||||
'topic[blogs_id_raw]': this.elements.blogs.getSelectionOrder()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
|
@ -43,11 +43,12 @@
|
|||
|
||||
{component 'field' template='select'
|
||||
label = $aLang.topic.add.fields.blog.label
|
||||
name = 'topic[blogs_id_raw][]'
|
||||
name = ''
|
||||
placeholder = 'Выберите блоги для публикации'
|
||||
inputClasses = 'js-topic-add-blogs'
|
||||
isMultiple = true
|
||||
selectedValue = ( ( $topic ) ? $topic->getBlogsId() : [] )
|
||||
inputAttributes = [ 'data-chosen-order' => {json var=$topic->getBlogsId()} ]
|
||||
items = $blogsSelect}
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b3486a234237a0fcf8276d48caf3c55f63055397
|
||||
Subproject commit 2bf4cab7d3ee0c6a0e603069e97df9c555bd3b42
|
Loading…
Reference in a new issue