Fixed stream filter reload.

This commit is contained in:
buddh4 2017-01-26 16:08:45 +01:00
parent f1b5bfba24
commit 657c31fa1c
14 changed files with 50 additions and 59 deletions

View File

@ -2,17 +2,17 @@ Javascript API
=======
Since version 1.2 HumHub provides a module based Javascript API within the `humhub` namespace.
Instead of using inline script blocks in your views it's highly recommended using the new module system for your
frontend scripts. The core components of this api are described in the following.
Instead of embeding inline script blocks into your view files, it's highly recommended to use the new module system for your js scripts.
The usage of this API and it's core components are described in the following.
## Modules
### Module Asset
Your Module script files should reside within the `asset/js` folder of your backend module and be appended at the bottom of your document by using yii's asset bundles.
Module script files should reside within the `resources/js` folder of your humhub module and should ideally be appended at the bottom of your document. This can be achieved by using [Asset Bundles](http://www.yiiframework.com/doc-2.0/guide-structure-assets.html):
Example:
```php
namespace humhub\modules\example\assets;
@ -21,29 +21,36 @@ use yii\web\AssetBundle;
class ExampleAsset extends AssetBundle
{
// You can also use View::POS_BEGIN to append your scripts to the beginning of the body element.
public $jsOptions = ['position' => \yii\web\View::POS_END];
public $sourcePath = '@example/assets';
public $css = [];
public $sourcePath = '@example/resources';
public $js = [
'js/humhub.example.js'
];
}
```
> Note: Make sure to add your assets after the core scripts, which are added within the html head.
> Note: Your Asset Bundle should reside in the `assets` subdirectory of your module.
### Module Registration
Modules are registered by calling the `humhub.initModule`. This function
requires an unique module id and your module function. The module function provides the following arumgents
New Module are registered by calling the `humhub.module` function as in the following example.
The first parameter of the `module` function is an unique module id. The second argument is the module function, which allows you to add module functions either by adding functions directly to the `module` argument or using the `module.export` function (prefered).
The `module` function provides the following arguments:
1. `module`: Your module instance, for exporting module functions and attributes.
2. `require`: Method for injecting other modules.
3. `$`: jQuery.
3. `$`: jQuery instance.
The following example shows the registraion of module with id 'example':
> Note: Only exported functions and attributes will be visible outside of the module.
```javascript
// After registration, all exported functions will be available under the namespace humhub.modules.example
humhub.initModule('example', function(module, require, $) {
humhub.module('example', function(module, require, $) {
// We require the client module
var client = require('client');
@ -58,13 +65,15 @@ humhub.initModule('example', function(module, require, $) {
// Some logic
}
var test = function() {
// Test function
}
// Export multiple values by calling module.export.
module.export({
test: test,
myFunction: function() {
...
},
init: function() {
//This code will automatically be executed when dom is ready.
}
});
});
@ -77,6 +86,9 @@ humhub.initModule('example.mySubmodule', function(module, require, $) {
}
```
Accessing your example module:
```javascript

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace activity\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace comment\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace content\_generated;
// This class was automatically generated by build task

View File

@ -19,20 +19,21 @@
*/
return array(
array('id' => '1', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e21', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '1', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 1, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '2', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e22', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '2', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 1, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '3', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e23', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '3', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 2, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2'),
array('id' => '4', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e24', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '4', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 2, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2'),
array('id' => '5', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e25', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '5', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 3, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3'),
array('id' => '6', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e26', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '6', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 3, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3'),
array('id' => '1', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e21', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '1', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 1, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
array('id' => '2', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e22', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '2', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 1, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
array('id' => '3', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e23', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '3', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 2, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2', 'stream_channel' => 'default'),
array('id' => '4', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e24', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '4', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 2, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '2', 'stream_channel' => 'default'),
array('id' => '5', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e25', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '5', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 3, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3', 'stream_channel' => 'default'),
array('id' => '6', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e26', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '6', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 3, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3', 'stream_channel' => 'default'),
// Posts to Space 1 (Id: 1) of User 1 & 3
array('id' => '7', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e27', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '7', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '8', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e28', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '8', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '9', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e29', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '9', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3'),
array('id' => '7', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e27', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '7', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
array('id' => '8', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e28', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '8', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
array('id' => '9', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e29', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '9', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 4, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '3', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '3', 'stream_channel' => 'default'),
// Posts to Space 2 of User 2 (Public & Private)
array('id' => '10', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e30', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '10', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 5, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '11', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e31', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '11', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 5, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'),
array('id' => '10', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e30', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '10', 'visibility' => '1', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 5, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
array('id' => '11', 'guid' => 'e0acdc54-13c8-4778-adc1-7302e3243e31', 'object_model' => 'humhub\modules\post\models\Post', 'object_id' => '11', 'visibility' => '0', 'pinned' => '0', 'archived' => '0', 'contentcontainer_id' => 5, 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1', 'stream_channel' => 'default'),
);

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace friendship\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace like\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace notification\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace space\_generated;
// This class was automatically generated by build task

View File

@ -384,6 +384,8 @@ humhub.module('stream', function(module, require, $) {
* @returns {humhub.stream_L5.Stream.prototype}
*/
Stream.prototype.init = function() {
this.lastContentId = 0;
this.lastEntryLoaded = false;
var that = this;
return new Promise(function(resolve, reject) {
that.clear();

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 25c2b4e8b8fd2158213a3465a3ef3b60
<?php //[STAMP] 74c0c3a2840b2412882616390669c863
namespace user\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 0468b7e2480518455b63a22d3aa6f7c2
<?php //[STAMP] e93907d5924b39a3cd4134cc6a6ea3a3
namespace user\_generated;
// This class was automatically generated by build task

View File

@ -1,4 +1,4 @@
<?php //[STAMP] ea40a453a487fa3632a18d4dadac1a58
<?php //[STAMP] 58ce1236f98ef299248ede5a3d5a3e7c
namespace _generated;
// This class was automatically generated by build task

View File

@ -1,24 +0,0 @@
<?php
namespace humhub\tests\codeception\unit\components\orm;
use tests\codeception\_support\HumHubDbTestCase;
use Codeception\Specify;
class SerializationTest extends HumHubDbTestCase
{
use Specify;
public function testSerializePost()
{
$model = \humhub\modules\post\models\Post::findOne(['id' => 1]);
$unserialized = unserialize(serialize($model));
$this->assertEquals($unserialized->id, 1);
$this->assertEquals($unserialized->message, 'User 1 Profile Post Private');
$this->assertEquals($model->test, 'aaa');
$this->assertEquals($unserialized->test, 'aaa');
}
}