这个问题与这个Nest jQuery UI sortables有关,但我无法解决我的问题.
这是问题所在:我有一个包含项目的主容器,这些项目是可以是未分组项目或组的div,其中包含其他项目.我可以通过拖动.multiply-groupdiv 来定义新组,然后我可以一次拖动所有组.这是代码:
<body>
<div class="multiply-container">
<div class="row multiply">Item 1</div>
<div class="row multiply">Item 2</div>
<div class="row multiply">Item 3</div>
<div class="row multiply-group"> Group 1</div>
<div class="row multiply">Item 4</div>
<div class="row multiply-group"> Group 2 </div>
<div class="row multiply">Item 5</div>
</div>
<script>
var groupWrap = function(){
$('.multiply-container').children().each(function(index, item){
if($(item).hasClass('multiply-group')){
$(item).nextUntil('.multiply-group').addBack().wrapAll('<div class="locked"></div>');
}
});
};
var updateMultiply = function(){
var $container = $('.multiply-container');
$container.children().each(function(index, item){
if($(item).hasClass('locked')){
$(item).children().each(function(i, elem){
$container.append($(elem));
});
$(item).remove();
}
});
groupWrap();
$('.multiply-container').sortable({
connectWith: '.locked', …Run Code Online (Sandbox Code Playgroud) 我在Laravel 5.4中创建了一个包,它建立了一个基本的后台.此程序包包含几个使用程序包内的控制器的路径.我想要做的是覆盖我的应用程序中包定义的路由,以插入自定义控制器.例如,如果我有路线
Route::get('login', [
'as' => 'admin.login',
'uses' => 'Auth\LoginController@showLoginForm'
]);
Run Code Online (Sandbox Code Playgroud)
在我的包中定义,将使用Vendor\Package\Controllers\Auth\LoginController我想为我的应用程序定义一个路由,该路由将覆盖该路由并使用App\Controllers\Auth\LoginController.
在应用程序路径文件中定义路径的明显方法失败,因为应用程序路径文件在程序包路由文件之前运行,因此将以程序包定义为准.
有没有办法完成这种事情?
我还试图获取特定路径RouteServiceProvider并使用该方法uses设置应该用于解决它的控制器,就像这样
public function boot()
{
parent::boot();
Route::get('admin.login')->uses('App\Http\Controllers\Admin\Auth\LoginController@showLoginForm');
}
Run Code Online (Sandbox Code Playgroud)
但这也无法实现假装.
关于我做错了什么的线索?
我知道,关于这个问题,这里和这里已经有类似的问题,但提出的每个解决方案都未能帮助我。大多数答案中也提到了这个库,但是(恕我直言)我想避免依赖外部库只是为了能够测试一个简单的控制器。
因此,我有一个非常简单的 api,可以使用 keycloak 生成的不记名令牌进行访问,我想测试控制器。沿着这些思路:
@Test
@DisplayName("Should be ok")
@WithMockUser
void whenCalled_shouldBeOk() throws Exception {
SecurityContext context = SecurityContextHolder.getContext();
Authentication authentication = context.getAuthentication();
mockMvc.perform(
post("/api/url/something")
.content("{}")
.contentType(APPLICATION_JSON)
.with(authentication(authentication))
).andExpect(status().isOk());
}
Run Code Online (Sandbox Code Playgroud)
问题是我总是会得到一个空指针异常,因为KeycloakDeploymentBuilder它缺少适配器配置。在我们的 SecurityConfig 中,我们扩展KeycloakWebSecurityConfigurerAdapter并执行应用程序工作所需的所有配置,但我未能在测试中模拟/绕过此过程。通常我会在测试中使用 @WithMockUser 注释找到解决此身份验证问题的方法(当不使用 keycloak 时),但这次不行。
没有办法模拟适配器或过滤进程来绕过这个问题吗?
我已经尝试了其他问题(图书馆除外)中回答的所有内容,但没有运气。如果您有任何可能有帮助的线索,或者至少为我指明了正确的方向(因为这可能是由于我缺乏对 Spring 安全性的了解),我将非常感激。
我设法使用该name属性创建了直接自嵌套的组件,并且一切运行正常。
<template>
<div>
<span>Hi, I'm component A!</span>
<component-a></component-a>
</div>
</template>
<script>
export default {
name: 'component-a',
components: {
'component-a': this
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
现在,我想创建间接的自嵌套组件。像这样:
ComponentA.vue:
<template>
<div>
<span>Hi, I'm component A!</span>
<component-b v-if="hasItems" v-for="item in items" :item="item"></component-b>
</div>
</template>
<script>
import ComponentB from './ComponentB.vue'
export default {
name: 'component-a',
components: {
'component-b': ComponentB
},
props: ['items'],
computed: {
hasItems() {
return this.items.length > 0
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
ComponentB.vue:
<template>
<div>
<span>Hi, I'm component B!</span>
<component-a v-if="hasItems" :items="item.items"></component-a> …Run Code Online (Sandbox Code Playgroud) 这个问题已在这里提出,但没有得到答复.现在我面临同样的问题,但在laravel 5.4.我有一个模型Book,一个模型ReadingSession和一个模型Comment.一本书有许多阅读课程,并有很多评论,但阅读会议也可以有意见.所以我的关系定义如下:
book.php中
protected $with = [
'author',
'readingSessions',
'userRating',
'ratings',
'comments'
];
public function users()
{
return $this->belongsToMany(User::class, 'user_book');
}
public function author()
{
return $this->belongsTo(Author::class);
}
public function allReadingSessions()
{
return $this->hasMany(ReadingSession::class);
}
public function readingSessions()
{
return $this->hasMany(ReadingSession::class)
->where('user_id', Auth::user()->id);
}
public function ratings()
{
return $this->hasMany(Rating::class);
}
public function userRating()
{
return $this->hasMany(Rating::class)
->where('user_id', Auth::user()->id);
}
public function comments()
{
return $this->morphMany('App\Models\Comment', 'commentable');
}
Run Code Online (Sandbox Code Playgroud)
ReadingSession.php
protected …Run Code Online (Sandbox Code Playgroud) 我正在构建一个简单的演示工具,我可以在其中创建演示文稿,命名它们并使用Vue js和Vuex添加/删除幻灯片以处理应用程序状态.一切都很好,但现在我正在尝试实现一个功能,检测演示文稿中的更改(标题已更改或幻灯片添加/删除),并且还无法找到适合它的解决方案.为简单起见,我仅举例说明标题的变化.现在,在我的Vuex商店,我有:
const state = {
presentations: handover.presentations, //array of objects that comes from the DB
currentPresentation: handover.presentations[0]
}
Run Code Online (Sandbox Code Playgroud)
在我的Presentation组件中,我有:
export default {
template: '#presentation',
props: ['presentation'],
data: () => {
return {
shadowPresentation: ''
}
},
computed: {
isSelected () {
if (this.getSelectedPresentation !== null) {
return this.presentation === this.getSelectedPresentation
}
return false
},
hasChanged () {
if (this.shadowPresentation.title !== this.presentation.title) {
return true
}
return false
},
...mapGetters(['getSelectedPresentation'])
},
methods: mapActions({
selectPresentation: 'selectPresentation'
}),
created () {
const …Run Code Online (Sandbox Code Playgroud) javascript ×3
laravel ×2
php ×2
vue.js ×2
eloquent ×1
java ×1
jquery ×1
jquery-ui ×1
keycloak ×1
laravel-5 ×1
laravel-5.4 ×1
nested ×1
polymorphism ×1
spring-boot ×1
vuex ×1