Skip to content
This repository was archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
Fix Small column and New User Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Davis committed Jan 23, 2016
1 parent e45539a commit 1bf94bb
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 38 deletions.
85 changes: 50 additions & 35 deletions js/forum/dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ System.register('davis/socialprofile/main', ['davis/socialprofile/models/SocialB
app.request({ method: "GET", url: theurl }).then(function (result) {
if (result.data.attributes.hasOwnProperty("buttons")) {
_this.socialaccs = JSON.parse(result.data.attributes.buttons);
_this.newuser = false;
} else {
_this.socialaccs = "";
_this.socialaccs = true;
_this.newuser = true;
}
m.redraw();
});
Expand All @@ -290,44 +292,57 @@ System.register('davis/socialprofile/main', ['davis/socialprofile/models/SocialB
// If request hasn't loaded yet, don't add any items.
if (!this.socialaccs) return;

var _loop = function (k) {
var curaccount = _this2.socialaccs[k];
if (curaccount["icon"] !== "") {
items.add(curaccount["icon"] + ' social-button', Badge.component({
type: "social",
icon: curaccount["icon"],
label: curaccount["title"],
if (!this.newuser) {
var _loop = function (k) {
var curaccount = _this2.socialaccs[k];
if (curaccount["icon"] !== "") {
items.add(curaccount["icon"] + ' social-button', Badge.component({
type: "social",
icon: curaccount["icon"],
label: curaccount["title"],
onclick: function onclick() {
window.open(curaccount["url"], '_blank');
}
}));
}
};

for (var k in this.socialaccs) {
_loop(k);
}
var settingsclass;
var settingsicon;
var settingslabel;
if (this.socialaccs["0"]["icon"] !== '' || this.socialaccs["1"]["icon"] !== '' || this.socialaccs["2"]["icon"] !== '' || this.socialaccs["3"]["icon"] !== '') {
settingsclass = 'social-settings';
settingsicon = 'cog';
settingslabel = app.translator.trans('davis-socialprofile.forum.edit.edit');
} else {
settingsclass = 'null-social-settings';
settingsicon = 'plus';
settingslabel = app.translator.trans('davis-socialprofile.forum.edit.add');
}
if (app.session.user === app.current.user) {
items.add('settings' + ' social-button', Badge.component({
type: "social " + settingsclass,
icon: settingsicon,
label: settingslabel,
onclick: function onclick() {
window.open(curaccount["url"], '_blank');
app.modal.show(new SocialButtonsModal());
}
}));
}), -1);
}
};

for (var k in this.socialaccs) {
_loop(k);
}
var settingsclass;
var settingsicon;
var settingslabel;
if (this.socialaccs["0"]["icon"] !== '' || this.socialaccs["1"]["icon"] !== '' || this.socialaccs["2"]["icon"] !== '' || this.socialaccs["3"]["icon"] !== '') {
settingsclass = 'social-settings';
settingsicon = 'cog';
settingslabel = app.translator.trans('davis-socialprofile.forum.edit.edit');
} else {
settingsclass = 'null-social-settings';
settingsicon = 'plus';
settingslabel = app.translator.trans('davis-socialprofile.forum.edit.add');
}
if (app.session.user === app.current.user) {
items.add('settings' + ' social-button', Badge.component({
type: "social " + settingsclass,
icon: settingsicon,
label: settingslabel,
onclick: function onclick() {
app.modal.show(new SocialButtonsModal());
}
}), -1);
if (app.session.user === app.current.user) {
items.add('settings' + ' social-button', Badge.component({
type: "social null-social-settings",
icon: "plus",
label: app.translator.trans('davis-socialprofile.forum.edit.add'),
onclick: function onclick() {
app.modal.show(new SocialButtonsModal());
}
}), -1);
}
}
});
});
Expand Down
15 changes: 14 additions & 1 deletion js/forum/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ app.initializers.add('davis-socialprofile-forum', function() {
app.request({method: "GET", url: theurl}).then(result => {
if(result.data.attributes.hasOwnProperty("buttons")) {
this.socialaccs = JSON.parse(result.data.attributes.buttons);
this.newuser = false;
} else {
this.socialaccs = "";
this.socialaccs = true;
this.newuser = true;
}
m.redraw();
});
Expand All @@ -27,6 +29,7 @@ app.initializers.add('davis-socialprofile-forum', function() {
// If request hasn't loaded yet, don't add any items.
if (!this.socialaccs) return;

if (!this.newuser) {
for (const k in this.socialaccs) {
const curaccount = this.socialaccs[k];
if (curaccount["icon"] !== "") {
Expand Down Expand Up @@ -61,5 +64,15 @@ app.initializers.add('davis-socialprofile-forum', function() {
onclick: function(){app.modal.show(new SocialButtonsModal())}
}), -1);
}
} else {
if (app.session.user === app.current.user) {
items.add('settings' + ' social-button', Badge.component({
type: "social null-social-settings",
icon: "plus",
label: app.translator.trans('davis-socialprofile.forum.edit.add'),
onclick: function(){app.modal.show(new SocialButtonsModal())}
}), -1);
}
}
});
});
3 changes: 1 addition & 2 deletions migrations/2016_01_14_000000_create_socialbuttons_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php namespace davis\socialprofile\Migration;

use Flarum\Database\AbstractMigration;
use Illuminate\Database\Schema\Blueprint;
class CreateSocialbuttonsTable extends AbstractMigration
Expand All @@ -9,7 +8,7 @@ public function up()
$this->schema->create('socialbuttons', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('buttons');
$table->longText('buttons');
});
}
public function down()
Expand Down

0 comments on commit 1bf94bb

Please sign in to comment.