1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Vue.JS init (#2459)

* Fixes for code coverage + style

* Integration tests for MultiDB

* Start sprinking Vue.JS
This commit is contained in:
David Bomba 2018-10-18 21:47:55 +11:00 committed by GitHub
parent f745c3f0a6
commit 0f64ade43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 107 additions and 32 deletions

View File

@ -27,8 +27,12 @@ class SignupRequest extends Request
{
return [
//'email' => 'required|string|email|max:100',
'password' => 'required|string|min:6',
'email' => new UniqueUserRule(),
'first_name' => 'required|string|max:100',
'last_name' => 'required|string:max:100',
'password' => 'required|string|min:6',
'email' => new UniqueUserRule(),
'privacy_policy' => 'required',
'terms_of_service' => 'required'
];
}
}

View File

@ -37,7 +37,7 @@ class MultiDB
* @param array $data
* @return bool
*/
public static function getUser(array $data)
public static function hasUser(array $data)
{
if (config('auth.providers.users.driver') == 'eloquent') //default eloquent = single DB
{

View File

@ -26,7 +26,7 @@
"perfect-scrollbar": "1.4.0",
"popper.js": "^1.12",
"simple-line-icons": "2.4.1",
"vue": "^2.5.7"
"vue": "^2.5.17"
},
"dependencies": {}
}

View File

@ -23,9 +23,12 @@
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./app/Providers</directory>
<directory suffix=".php">./app/Http</directory>
<directory suffix=".php">./app/Http</directory>
<directory suffix=".php">./app/Models</directory>
<file>./app/Console/Kernel.php</file>
<file>./app/Exceptions/Handler.php</file>
<file>./app/Constants.php</file>
<file>./app/Libraries/OFX.php</file>
<file>./app/Exceptions/Handler.php</file>
</exclude>
</whitelist>

8
public/js/ninja.js vendored

File diff suppressed because one or more lines are too long

3
resources/js/app.js vendored
View File

@ -5,10 +5,11 @@
* building robust, powerful web applications using Vue and Laravel.
*/
//require('./bootstrap');
require('./bootstrap');
window.Vue = require('vue');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application

View File

@ -1,19 +1,3 @@
window._ = require('lodash');
window.Popper = require('popper.js').default;
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the

View File

@ -16,6 +16,9 @@
ga('send', 'event', category, action, this.src);
}
</script>
<script>
Vue.config.devtools = true;
</script>
@else
<script>
function gtag(){}

View File

@ -4,7 +4,7 @@
<body class="app flex-row align-items-center">
<div class="container">
<div class="container" id="signup">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mx-4">
@ -17,6 +17,36 @@
{{ html()->form('POST', route('signup.submit'))->open() }}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="icon-user"></i>
</span>
</div>
<input id="first_name" type="text" class="form-control{{ $errors->has('first_name') ? ' is-invalid' : '' }}" name="first_name" value="{{ old('first_name') }}" placeholder="@lang('texts.first_name')" required autofocus>
@if ($errors->has('first_name'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('first_name') }}</strong>
</span>
@endif
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="icon-user"></i>
</span>
</div>
<input id="last_name" type="text" class="form-control{{ $errors->has('last_name') ? ' is-invalid' : '' }}" name="last_name" value="{{ old('last_name') }}" placeholder="@lang('texts.last_name')" required autofocus>
@if ($errors->has('last_name'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('last_name') }}</strong>
</span>
@endif
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
@ -49,7 +79,21 @@
@endif
</div>
<button class="btn btn-block btn-success" type="submit">@lang('texts.create_account')</button>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="terms_of_service" name="terms_of_service" value="" v-model="checked1" {{(old('terms_of_service') == "1") ? 'checked': ''}}>
<label class="form-check-label" for="terms_of_service">
@lang('texts.terms_of_service')
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="privacy_policy" name="privacy_policy" value="" v-model="checked2" {{(old('privacy_policy') == "1") ? 'checked': ''}}>
<label class="form-check-label" for="privacy_policy">
@lang('texts.privacy_policy')
</label>
</div>
<button class="btn btn-block btn-success" type="submit" :disabled="!isDisabled">@lang('texts.create_account')</button>
</div>
{{ html()->form()->close() }}
@ -73,9 +117,26 @@
</div>
</div>
<script>
new Vue({
el : '#signup',
data: {
checked1 : false,
checked2 : false
},
computed: {
isDisabled: function(){
return (this.checked1 && this.checked2);
}
}
});
</script>
@endsection
</body>
</html>

View File

@ -60,7 +60,7 @@ class MultiDBUserTest extends TestCase
public function test_oauth_user_db2_exists()
{
$user = MultiDB::getUser(['email' => 'db2@example.com', 'oauth_user_id' => 'abc']);
$user = MultiDB::hasUser(['email' => 'db2@example.com', 'oauth_user_id' => 'abc']);
$this->assertEquals($user->email, 'db2@example.com');
@ -68,12 +68,31 @@ class MultiDBUserTest extends TestCase
public function test_oauth_user_db1_exists()
{
$user = MultiDB::getUser(['email' => 'db1@example.com', 'oauth_user_id' => '123']);
$user = MultiDB::hasUser(['email' => 'db1@example.com', 'oauth_user_id' => '123']);
$this->assertEquals($user->email, 'db1@example.com');
}
public function test_check_user_exists()
{
$this->assertTrue(MultiDB::checkUserEmailExists('db1@example.com'));
}
public function test_check_user_does_not_exist()
{
$this->assertFalse(MultiDB::checkUserEmailExists('bademail@example.com'));
}
/*
* This is what you do when you demand 100% code coverage :/
*/
public function test_set_db_invokes()
{
$this->expectNotToPerformAssertions(MultiDB::setDB('db-ninja-1'));
}
public function tearDown()
{
DB::connection('db-ninja-1')->table('users')->delete();

View File

@ -16,7 +16,7 @@ use Tests\TestCase;
*/
class UniqueEmailTest extends TestCase
{
//use InteractsWithDatabase;
use InteractsWithDatabase;
//use DatabaseMigrations;
protected $rule;