Skip to content

Commit fe18355

Browse files
committed
add VueJS in Chamilo
1 parent a833631 commit fe18355

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

assets/js/VueConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const VueConfig = {
2+
delimiters: ['[[', ']]']
3+
};

assets/js/app.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ const legacyIndex = Routing.generate('legacy_index');
1717
const mainUrl = Routing.generate('web.main');
1818
const webAjax = Routing.generate('web.ajax');
1919

20-
/*console.log(homePublicUrl);
21-
console.log(legacyIndex);
22-
console.log(mainUrl);
23-
console.log(webAjax);*/
24-
2520
var ajax_url = webAjax + 'chat.ajax.php';
2621
var online_button = '<img src="' + homePublicUrl + 'img/statusonline.png">';
2722
var offline_button = '<img src="' + homePublicUrl + 'img/statusoffline.png">';
@@ -31,7 +26,36 @@ var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}';*/
3126
var connect_lang = 'ChatConnected';
3227
var disconnect_lang = 'ChatDisconnected';
3328

29+
// Import Vue and Components
30+
import Vue from 'vue';
31+
import {VueConfig} from './VueConfig';
32+
import Example from './components/Example'
33+
34+
3435
$(function() {
36+
// Create App Aplication Vue
37+
new Vue(
38+
Object.assign(VueConfig, {
39+
el: '#app_header',
40+
components: {Example},
41+
data() {
42+
return {
43+
chamilo: ''
44+
}
45+
},
46+
methods: {
47+
getConsole() {
48+
console.log("Hello Vuejs");
49+
}
50+
}, created() {
51+
this.chamilo = "Hello Chamilo";
52+
this.getConsole();
53+
console.log(this.chamilo);
54+
}
55+
})
56+
);
57+
58+
3559
var webCidReq = '&cidReq=' + $('body').attr('data-course-code');
3660
window.webCidReq = webCidReq;
3761

assets/js/components/Example.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<div>
3+
<p>This is an example of a new components in VueJs</p>
4+
</div>
5+
</template>
6+
<script>
7+
export default {
8+
name: "example"
9+
}
10+
</script>
11+
<style scoped>
12+
</style>

src/ThemeBundle/Resources/views/Layout/header.html.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ $(function () {
6666
});
6767
});
6868
</script>
69-
<header class="app-header navbar">
69+
<header id="app_header" class="app-header navbar">
7070
<button class="navbar-toggler sidebar-toggler d-lg-none mr-auto" type="button" data-toggle="sidebar-show">
7171
<span class="navbar-toggler-icon"></span>
7272
</button>
@@ -85,6 +85,9 @@ $(function () {
8585
{{ "Course catalog"|trans }}
8686
</a>
8787
</li>
88+
<li>
89+
[[ chamilo ]]
90+
</li>
8891
<form class="form-inline my-2 my-lg-0">
8992
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
9093
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Encore
3131
// .enableVersioning(Encore.isProduction())
3232

3333
.enableSassLoader()
34-
34+
.enableVueLoader()
3535
.autoProvidejQuery()
3636
;
3737

0 commit comments

Comments
 (0)