Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding Avatar functionality to Groups and Users WIP

  • Loading branch information...
commit 460f8896bc1fc02ed9934d35339c5f5cab97f02b 1 parent b5e7ba2
@hamishcrittenden hamishcrittenden authored
View
40 Src/Bowerbird.Core/Config/Constants.cs
@@ -12,6 +12,8 @@
*/
+using System;
+
namespace Bowerbird.Core.Config
{
public static class Constants
@@ -20,12 +22,49 @@ public static class Constants
public static string AppRootId = "bowerbird/approot";
}
+ /// <summary>
+ /// Set an Avatar Type when creating new entity which requires a blank Avatar.
+ /// Possibilities are Project, Team, Organisation and User
+ /// </summary>
+ public enum AvatarDefaultType
+ {
+ Project,
+ Team,
+ Organisation,
+ User
+ }
+
public static class AvatarUris
{
public static string DefaultUser = "/img/default-user-avatar.jpg";
public static string DefaultProject = "/img/default-project-avatar.jpg";
public static string DefaultTeam = "/img/default-team-avatar.jpg";
public static string DefaultOrganisation = "/img/default-organisation-avatar.jpg";
+
+ public static string AvatarTypeUris(this AvatarDefaultType avatarType)
+ {
+ switch (avatarType)
+ {
+ case AvatarDefaultType.Project:
+ {
+ return DefaultProject;
+ }
+ case AvatarDefaultType.Team:
+ {
+ return DefaultTeam;
+ }
+ case AvatarDefaultType.Organisation:
+ {
+ return DefaultOrganisation;
+ }
+ case AvatarDefaultType.User:
+ {
+ return DefaultUser;
+ }
+ default:
+ throw new ApplicationException("No Avatar Type Specified");
+ }
+ }
}
public static class ActivitySender
@@ -126,4 +165,5 @@ public static class Default
public static int PageSize = 10;
public static int PageMax = 100;
}
+
}
View
16 Src/Bowerbird.Web/Builders/ProjectsViewModelBuilder.cs
@@ -11,6 +11,7 @@
*/
using System.Linq;
+using Bowerbird.Core.Config;
using Bowerbird.Core.DesignByContract;
using Bowerbird.Core.DomainModels;
using Bowerbird.Core.Indexes;
@@ -61,6 +62,19 @@ public object BuildProject(IdInput idInput)
return MakeProject(project);
}
+ public object BuildNewProject()
+ {
+ return new
+ {
+ Id = "",
+ Name = "New Project",
+ Description = "New Project",
+ Website = "",
+ Avatar = _avatarFactory.MakeDefaultAvatar(AvatarDefaultType.Project, "New Project"),
+ MemberCount = 1
+ };
+ }
+
public object BuildProjectList(PagingInput pagingInput)
{
RavenQueryStatistics stats;
@@ -184,7 +198,7 @@ private object MakeProject(All_Groups.Result result)
{
return new
{
- Id = result.Project.Id,
+ result.Project.Id,
result.Project.Name,
result.Project.Description,
result.Project.Website,
View
4 Src/Bowerbird.Web/Controllers/MediaResourcesController.cs
@@ -83,9 +83,9 @@ public ActionResult PostUpload(string key, string originalFileName, HttpPostedFi
[HttpPost]
[Authorize]
- public ActionResult AvatarUpload(string key, string originalFileName, HttpPostedFileBase file)
+ public ActionResult AvatarUpload(HttpPostedFileBase file, string recordType)
{
- return ProcessPostedImage(key, originalFileName, file, "user");
+ return ProcessPostedImage(string.Empty, string.Empty, file, recordType);
}
private ActionResult ProcessPostedImage(string key, string originalFileName, HttpPostedFileBase file, string recordType)
View
12 Src/Bowerbird.Web/Controllers/ProjectsController.cs
@@ -214,7 +214,11 @@ public ActionResult CreateForm(IdInput idInput)
Name = "Enter Name",
Description = "Enter Description",
Website = "Enter Website",
- ImgUrl = "/img/default-project-avatar.jpg"
+ Avatar = new
+ {
+ UrlToImage = "../img/default-team-avatar.jpg",
+ AltTag = "Project"
+ }
},
Teams = GetTeams(_userContext.GetAuthenticatedUserId())
@@ -327,7 +331,11 @@ public ActionResult Leave(IdInput idInput)
[HttpPost]
public ActionResult Create(ProjectCreateInput createInput)
{
- if (!_userContext.HasGroupPermission(PermissionNames.CreateProject, createInput.Team ?? Constants.AppRootId))
+ Check.RequireNotNull(createInput, "createInput");
+
+ var groupId = createInput.Team != null ? createInput.Team.PrependWith("teams/") : Constants.AppRootId;
+
+ if (!_userContext.HasGroupPermission(PermissionNames.CreateProject, groupId))
{
return HttpUnauthorized();
}
View
9 Src/Bowerbird.Web/Controllers/TeamsController.cs
@@ -200,14 +200,19 @@ public ActionResult CreateForm(IdInput idInput)
Name = "Enter Name",
Description = "Enter Description",
Website = "Enter Website",
- ImgUrl = "../img/default-team-avatar.jpg"
+ Avatar = new
+ {
+ UrlToImage = "../img/default-team-avatar.jpg",
+ AltTag = "Project"
+ }
},
+
Organisations = GetOrganisations(_userContext.GetAuthenticatedUserId())
};
if (Request.IsAjaxRequest())
{
- return new JsonNetResult(ViewBag.Model);
+ return new JsonNetResult(new {Model = ViewBag.Model});
}
ViewBag.PrerenderedView = "teams";
View
11 Src/Bowerbird.Web/Factories/AvatarFactory.cs
@@ -3,10 +3,8 @@
Developers:
* Frank Radocaj : frank@radocaj.com
* Hamish Crittenden : hamish.crittenden@gmail.com
-
Project Manager:
* Ken Walker : kwalker@museum.vic.gov.au
-
Funded by:
* Atlas of Living Australia
@@ -46,6 +44,15 @@ IMediaFilePathService mediaFilePathService
#region Methods
+ public object MakeDefaultAvatar(AvatarDefaultType avatarType, string altTag)
+ {
+ return new
+ {
+ AltTag = altTag,
+ UrlToImage = avatarType.AvatarTypeUris()
+ };
+ }
+
public object Make(Team team)
{
return new
View
8 Src/Bowerbird.Web/Factories/IAvatarFactory.cs
@@ -3,15 +3,14 @@
Developers:
* Frank Radocaj : frank@radocaj.com
* Hamish Crittenden : hamish.crittenden@gmail.com
-
Project Manager:
* Ken Walker : kwalker@museum.vic.gov.au
-
Funded by:
* Atlas of Living Australia
*/
+using Bowerbird.Core.Config;
using Bowerbird.Core.DomainModels;
namespace Bowerbird.Web.Factories
@@ -19,8 +18,13 @@ namespace Bowerbird.Web.Factories
public interface IAvatarFactory
{
object Make(Team team);
+
object Make(Project project);
+
object Make(Organisation organisation);
+
object Make(User user);
+
+ object MakeDefaultAvatar(AvatarDefaultType avatarType, string altTag);
}
}
View
1  Src/Bowerbird.Website/Bowerbird.Website.csproj
@@ -131,6 +131,7 @@
<Content Include="js\bowerbird\collections\streamItemCollection.js" />
<Content Include="js\bowerbird\collections\userCollection.js" />
<Content Include="js\bowerbird\controllers\observationController.js" />
+ <Content Include="js\bowerbird\models\avatar.js" />
<Content Include="js\bowerbird\models\referenceSpecies.js" />
<Content Include="js\bowerbird\models\species.js" />
<Content Include="js\bowerbird\models\organisation.js" />
View
16 Src/Bowerbird.Website/Views/Shared/ProjectForm.mustache
@@ -40,17 +40,13 @@
</div>
</div>
</fieldset>
- <fieldset id="media-resources-fieldset">
+ <fieldset id="avatar-fieldset">
<legend>Avatar Image</legend>
- <div id="avatar" class="field">
- <div>
- <label for="avatar">Project Avatar</label>
- </div>
- <div id="avatar-field" class="field">
- <img src="{{Model.Project.ImgUrl}}" />
- </div>
- <div id="avatar-upload-button" class="button avatar-upload-button">
- Change Avatar<input id="fileupload" type="file" name="file" multiple="" />
+ <div id="avatar-viewer" class="field">
+ </div>
+ <div id="avatar-add-pane" class="field">
+ <div id="media-resource-upload-button" class="button media-resource-upload-button">
+ Change Avatar Image<input id="fileupload" type="file" name="file" multiple="" />
</div>
</div>
</fieldset>
View
3  Src/Bowerbird.Website/Views/Shared/avatarchoosefile.mustache
@@ -1,3 +1,4 @@
-<div id="media-resource-upload-button" class="button media-resource-upload-button">
+<p>Avatar Choose File</p>
+<div id="media-resource-upload-button" class="button media-resource-upload-button">
Change Avatar Image<input id="fileupload" type="file" name="file" multiple="" />
</div>
View
13 Src/Bowerbird.Website/Views/Shared/avataruploader.mustache
@@ -14,4 +14,15 @@
</div>
</div>
</div>
-</div>
+</div>
+
+<!--
+<div>
+ <label for="avatar">Project Avatar</label>
+</div>
+<div id="avatar-field" class="field">
+ <img src="{{Model.Project.ImgUrl}}" />
+ </div>
+ <div id="avatar-upload-button" class="button avatar-upload-button">
+ Change Avatar<input id="fileupload" type="file" name="file" multiple="" />
+</div>-->
View
2  Src/Bowerbird.Website/Web.config
@@ -16,7 +16,7 @@
<!--DEV-->
<bowerbird>
<!--<environment rootPath="c:\projects\bowerbird.web\src\bowerbird.website" rootUri="http://localhost:65060" />-->
- <environment rootPath="c:\projects\bowerbird\bowerbird-web\src\bowerbird.website" rootUri="http://localhost:65060" />
+ <environment rootPath="c:\projects\bowerbird.web\src\bowerbird.website" rootUri="http://localhost:65060" />
<documentStore databaseName="" url="http://localhost:8080/" />
<email serverName="vespa.mv.vic.gov.au" adminAccount="fradocaj@museum.vic.gov.au" resetPasswordRelativeUri="/account/resetpassword/{0}" />
<media rootUri="/media/" relativePath="\media\" />
View
24 Src/Bowerbird.Website/js/bowerbird/models/avatar.js
@@ -0,0 +1,24 @@
+/// <reference path="../../libs/log.js" />
+/// <reference path="../../libs/require/require.js" />
+/// <reference path="../../libs/jquery/jquery-1.7.2.js" />
+/// <reference path="../../libs/underscore/underscore.js" />
+/// <reference path="../../libs/backbone/backbone.js" />
+/// <reference path="../../libs/backbone.marionette/backbone.marionette.js" />
+
+// MediaResource
+// -------------
+
+define(['jquery', 'underscore', 'backbone', 'app'], function ($, _, Backbone, app) {
+
+ var Avatar = Backbone.Model.extend({
+ defaults: {
+ AltTag: 0,
+ UrlToImage: '/img/image-upload.png'
+ },
+
+ idAttribute: 'Id'
+ });
+
+ return MediaResource;
+
+});
View
10 Src/Bowerbird.Website/js/bowerbird/models/project.js
@@ -12,6 +12,12 @@ define(['jquery', 'underscore', 'backbone', 'app'], function ($, _, Backbone, ap
var Project = Backbone.Model.extend({
defaults: {
+ Id: '',
+ Name: '',
+ Description: '',
+ Website: '',
+ Avatar: null,
+ Team: null,
Type: 'Project'
},
@@ -29,6 +35,10 @@ define(['jquery', 'underscore', 'backbone', 'app'], function ($, _, Backbone, ap
Team: this.get('Team'),
Type: 'Project'
};
+ },
+
+ setAvatar: function (mediaResource) {
+ this.set('Avatar', mediaResource.id);
}
});
View
9 Src/Bowerbird.Website/js/bowerbird/views/avatarItemView.js
@@ -20,16 +20,19 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich'], function ($, _, Backb
'click .remove-media-resource-button': 'removeMediaResource'
},
- template: "AvatarUploaded",
+ //template: "AvatarUploaded",
initialize: function (options) {
_.extend(this, Backbone.Events);
- _.bindAll(this, 'showTempMedia', 'showUploadedMedia');
+ _.bindAll(this,
+ 'showTempMedia',
+ 'showUploadedMedia'
+ );
this.mediaResource = options.MediaResource;
this.mediaResource.on('change:mediumImageUri', this.showUploadedMedia);
},
- onRender: function () {
+ render: function () {
// this.$el.append(ich.AvatarUploaded(this.MediaResource.toJSON()));
// return this;
},
View
77 Src/Bowerbird.Website/js/bowerbird/views/editAvatarView.js
@@ -2,23 +2,22 @@
/// <reference path="../../libs/require/require.js" />
/// <reference path="../../libs/jquery/jquery-1.7.2.js" />
/// <reference path="../../libs/underscore/underscore.js" />
+/// <reference path="../../libs/icanhaz/icanhaz.js" />
/// <reference path="../../libs/backbone/backbone.js" />
/// <reference path="../../libs/backbone.marionette/backbone.marionette.js" />
// EditAvatarView
// -------------------------
-define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'models/mediaresource', 'views/avataritemview', 'loadimage'], function ($, _, Backbone, app, ich, AvatarItemView, loadImage) {
+define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'views/avataritemview', 'loadimage', 'models/mediaresource'], function ($, _, Backbone, app, ich, AvatarItemView, loadImage, MediaResource) {
EditAvatarView = Backbone.View.extend({
- className: 'button media-resource-upload-button',
+ id: 'avatar-fieldset',
- events: {
- 'click .remove-media-resource-button': 'removeMediaResource'
- },
-
- template: "AvatarChooseFile",
+ // events: {
+ // 'click .remove-media-resource-button': 'removeMediaResource'
+ // },
initialize: function (options) {
_.extend(this, Backbone.Events);
@@ -27,29 +26,36 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'models/mediaresource'
'_initMediaUploader',
'_onUploadDone',
'_onSubmitUpload',
- '_onUploadAdd',
- 'removeMediaResource'
+ '_onUploadAdd'//,
+ //'removeMediaResource'
);
- this.group = options.group;
+ this.model = options.model;
this.currentUploadKey = 0;
this.avatarItemView = null;
},
- onShow: function () {
- this._showDetails();
- },
-
- _showDetails: function () {
- //ich.AvatarChooseFile().appendTo($('#avatar-add-pane'));
+ render: function () {
+ log('editAvatarView:render');
this._initMediaUploader();
- //return this;
+ $('#avatar-viewer').append('<img src="' + this.model.get('Avatar').UrlToImage + '" />');
+ return this;
},
+ // onShow: function () {
+ //
+ // },
+
+ // _showDetails: function () {
+ // //ich.AvatarChooseFile().appendTo($('#avatar-add-pane'));
+ // this._initMediaUploader();
+ // //return this;
+ // },
+
_initMediaUploader: function () {
$('#fileupload').fileupload({
dataType: 'json',
paramName: 'file',
- url: '/mediaresource/avatarupload',
+ url: '/mediaresources/avatarupload',
add: this._onUploadAd,
submit: this._onSubmitUpload,
done: this._onUploadDone,
@@ -58,7 +64,38 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'models/mediaresource'
},
_onUploadAdd: function (e, data) {
+ log('editAvatarView:_onUploadAdd');
+ this.currentUploadKey++;
+ var mediaResource = new MediaResource({ Key: this.currentUploadKey.toString() });
+ this.model.setAvatar(mediaResource);
+
+ //this.avatarItemView = new AvatarItemView({ model: mediaResource });
+ //avatarItemView.on('avataritemview:remove', this._removeMediaResource);
+ //this.mediaResourceItemViews.push(mediaResourceItemView);
+ //$('#media-resource-add-pane').before(mediaResourceItemView.render().el);
+
+ //$('#avatar-viewer').append(this.avatarItemView.render().el);
+
+ var self = this;
+ var tempImage = loadImage(
+ data.files[0],
+ function (img) {
+ if (img.type === "error") {
+ //log('Error loading image', img);
+ } else {
+ self.filesAdded++;
+ mediaResourceItemView.showTempMedia(img);
+ self._showMediaResourceItemView(self, mediaResourceItemView, $(img).width(), self.filesAdded === data.originalFiles.length);
+ }
+ },
+ { maxHeight: 220 }
+ );
+
+ if (!tempImage) {
+ alert('No support for file/blob API!');
+ }
+ data.submit();
},
_onSubmitUpload: function (e, data) {
@@ -87,10 +124,10 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'models/mediaresource'
);
},
- removeMediaResource: function () {
+ _removeMediaResource: function () {
this.group.set('Avatar', null);
this.avatarItemView = null;
- ich["AvatarChooseFile"].appendTo(this.$el.find('#avatar-add-pane'));
+ this.$el.find('#avatar-add-pane').append(ich.AvatarChooseFile());
this._initMediaUploader();
}
});
View
80 Src/Bowerbird.Website/js/bowerbird/views/projectFormLayoutView.js
@@ -1,6 +1,8 @@
/// <reference path="../../libs/log.js" />
/// <reference path="../../libs/require/require.js" />
/// <reference path="../../libs/jquery/jquery-1.7.2.js" />
+/// <reference path="../../libs/jquery/jquery.fileupload.js" />
+/// <reference path="../../libs/jquery/load-image.js" />
/// <reference path="../../libs/underscore/underscore.js" />
/// <reference path="../../libs/backbone/backbone.js" />
/// <reference path="../../libs/backbone.marionette/backbone.marionette.js" />
@@ -8,7 +10,7 @@
// ProjectFormLayoutView
// -------------------------
-define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'multiselect', 'loadimage', 'fileupload'], function ($, _, Backbone, app, ich, loadImage) {
+define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'loadimage', 'views/editavatarview', 'fileupload', 'multiselect'], function ($, _, Backbone, app, ich, loadImage, EditAvatarView) {
var ProjectFormLayoutView = Backbone.Marionette.Layout.extend({
@@ -16,6 +18,10 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'multiselect', 'loadim
template: 'ProjectForm',
+ regions: {
+ avatar: '#avatar-fieldset',
+ },
+
events: {
'click #cancel': '_cancel',
'click #save': '_save',
@@ -28,8 +34,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'multiselect', 'loadim
initialize: function (options) {
log('projectFormLayoutView:initialize');
this.teams = options.teams;
- //this._showDetails();
- //this._initMediaUploader();
},
serializeData: function () {
@@ -45,17 +49,21 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'multiselect', 'loadim
onShow: function () {
log('projectFormLayoutView:onShow');
this._showDetails();
- this._initMediaUploader();
},
showBootstrappedDetails: function () {
log('projectFormLayoutView:showBootstrappedDetails');
this.initializeRegions();
- this._showDetails();
+ //this._showDetails();
},
_showDetails: function () {
log('projectFormLayoutView:showDetails');
+
+ var editAvatarView = new EditAvatarView({ el: '#avatar-fieldset', model: this.model });
+ //this.avatar.attachView(editAvatarView);
+ editAvatarView.render();
+
this.teamListSelectView = this.$el.find("#Team").multiSelect({
selectAll: false,
singleSelect: true,
@@ -71,68 +79,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'ich', 'multiselect', 'loadim
});
},
- _initMediaUploader: function () {
- log('projectFormLayoutView:initMediaUploader');
- $('#fileupload').fileupload({
- dataType: 'json',
- paramName: 'file',
- url: '/mediaresource/avatarupload',
- add: this._onUploadAdd,
- submit: this._onSubmitUpload,
- done: this._onUploadDone,
- limitConcurrentUploads: 1
- });
- },
-
- _onUploadAdd: function (e, data) {
- log('projectFormLayoutView:onUploadAdd');
- var self = this;
- var tempImage = loadImage(
- data.files[0],
- function (img) {
- if (img.type === "error") {
- log('Error loading image', img);
- } else {
- this._showTempMedia(img);
- }
- },
- { maxHeight: 220 }
- );
-
- if (!tempImage) {
- alert('No support for file/blob API!');
- }
-
- data.submit();
- },
-
- _onSubmitUpload: function (e, data) {
- log('projectFormLayoutView:onSubmitUpload');
- data.formData = { Key: this.currentUploadKey, OriginalFileName: data.files[0].name };
- },
-
- _onUploadDone: function (e, data) {
- log('projectFormLayoutView:onUploadDone');
- var mediaResource = this.model.mediaResources.find(function (item) {
- return item.get('Key') === data.result.Key;
- });
- mediaResource.set(data.result);
- this._showUploadedMedia(mediaResource);
- },
-
- _showTempMedia: function (img) {
- log('projectFormLayoutView:showTempMedia');
- var $image = $(img);
- this.$el.find('#avatar-field img').replaceWith($image);
- this.$el.width($image.width());
- this.imageWidth = $image.width();
- },
-
- _showUploadedMedia: function (mediaResource) {
- log('projectFormLayoutView:showUploadedMedia');
- this.$el.find('#avatar-field img').replaceWith($('<img src="' + mediaResource.get('MediumImageUri') + '" alt="" />'));
- },
-
_contentChanged: function (e) {
log('projectFormLayoutView:contentChanged');
var target = $(e.currentTarget);
View
10 Src/Bowerbird.ncrunchsolution
@@ -0,0 +1,10 @@
+<SolutionConfiguration>
+ <FileVersion>0</FileVersion>
+ <AutoEnableOnStartup>Default</AutoEnableOnStartup>
+ <AllowParallelTestExecution>false</AllowParallelTestExecution>
+ <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
+ <FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
+ <FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
+ <FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
+ <EngineModes>Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk</EngineModes>
+</SolutionConfiguration>
View
448 a
@@ -1,448 +0,0 @@
-commit 21f0ec5d6217f6fba0ea741117f7b4327556f51d
-Merge: 62344ba bacb82e
-Author: hamishcrittenden <hamish.crittenden@gmail.com>
-Date: Fri Mar 30 13:01:49 2012 +1100
-
- WIP on master: 62344ba avatar editing capability WIP
-
-diff --cc Docs/Model.vsd
-index 9b9caef,9b9caef..0250c98
-Binary files differ
-diff --cc Src/Bowerbird.Web/Controllers/Members/OrganisationController.cs
-index 15e62e5,15e62e5..03c1630
---- a/Src/Bowerbird.Web/Controllers/Members/OrganisationController.cs
-+++ b/Src/Bowerbird.Web/Controllers/Members/OrganisationController.cs
-@@@ -92,10 -92,10 +92,10 @@@ namespace Bowerbird.Web.Controllers.Mem
- [HttpPost]
- public ActionResult Create(OrganisationCreateInput createInput)
- {
--- if (!_userContext.HasGlobalPermission(PermissionNames.CreateOrganisation))
--- {
--- return HttpUnauthorized();
--- }
-++ //if (!_userContext.HasGlobalPermission(PermissionNames.CreateOrganisation))
-++ //{
-++ // return HttpUnauthorized();
-++ //}
- 
- if (!ModelState.IsValid)
- {
-diff --cc Src/Bowerbird.Web/Controllers/Members/ProjectController.cs
-index d9af9f8,d9af9f8..06dede7
---- a/Src/Bowerbird.Web/Controllers/Members/ProjectController.cs
-+++ b/Src/Bowerbird.Web/Controllers/Members/ProjectController.cs
-@@@ -104,10 -104,10 +104,10 @@@ namespace Bowerbird.Web.Controllers.Mem
- [HttpPost]
- public ActionResult Create(ProjectCreateInput createInput)
- {
--- if (!_userContext.HasGlobalPermission(PermissionNames.CreateProject))
--- {
--- return HttpUnauthorized();
--- }
-++ //if (!_userContext.HasGlobalPermission(PermissionNames.CreateProject))
-++ //{
-++ // return HttpUnauthorized();
-++ //}
- 
- if (!ModelState.IsValid)
- {
-@@@ -165,7 -165,7 +165,8 @@@
- {
- Description = createInput.Description,
- Name = createInput.Name,
--- UserId = _userContext.GetAuthenticatedUserId()
-++ UserId = _userContext.GetAuthenticatedUserId(),
-++ AvatarId = createInput.Avatar
- };
- }
- 
-diff --cc Src/Bowerbird.Web/Controllers/Members/TeamController.cs
-index e3ed3e3,e3ed3e3..20ef433
---- a/Src/Bowerbird.Web/Controllers/Members/TeamController.cs
-+++ b/Src/Bowerbird.Web/Controllers/Members/TeamController.cs
-@@@ -105,10 -105,10 +105,10 @@@ namespace Bowerbird.Web.Controllers.Mem
- [HttpPost]
- public ActionResult Create(TeamCreateInput createInput)
- {
--- if (!_userContext.HasGlobalPermission(PermissionNames.CreateTeam))
--- {
--- return HttpUnauthorized();
--- }
-++ //if (!_userContext.HasGlobalPermission(PermissionNames.CreateTeam))
-++ //{
-++ // return HttpUnauthorized();
-++ //}
- 
- if (!ModelState.IsValid)
- {
-diff --cc Src/Bowerbird.Web/ViewModels/Members/ProjectCreateInput.cs
-index 32b19e8,32b19e8..de4d4ee
---- a/Src/Bowerbird.Web/ViewModels/Members/ProjectCreateInput.cs
-+++ b/Src/Bowerbird.Web/ViewModels/Members/ProjectCreateInput.cs
-@@@ -38,6 -38,6 +38,9 @@@ namespace Bowerbird.Web.ViewModels.Memb
- 
- public string Website { get; set; }
- 
-++ // this is the mediaresourceid of the avatar mediaresrouce
-++ public string Avatar { get; set; }
-++
- #endregion
- 
- #region Methods
-diff --cc Src/Bowerbird.Website/Areas/Members/Views/Home/Index.cshtml
-index 4f8bb1f,4f8bb1f..7a72e7e
---- a/Src/Bowerbird.Website/Areas/Members/Views/Home/Index.cshtml
-+++ b/Src/Bowerbird.Website/Areas/Members/Views/Home/Index.cshtml
-@@@ -149,18 -149,18 +149,6 @@@
- @Html.Partial("_TeamCreate")
- </script>
- 
---<!-- {{ avataruploaded: used for displaying the latest uploaded avatar media }} -->
---<script id="avataruploaded" type="text/html">
--- <div>
--- <img src="{{mediumImageUri}}" alt="" />
--- </div>
--- <div>
--- <input type="button" value="View" class="view-media-resource-button" />
--- <input type="button" value="Add Caption" class="add-caption-button" />
--- <input type="button" value="Remove" class="remove-media-resource-button" />
--- </div>
---</script>
---
- <!-- {{ user: used where user avatar and name is needed }} -->
- <script id="user" type="text/html">
- <span class="user-avatar">
-@@@ -286,7 -286,7 +274,6 @@@
- <script type="text/javascript" src="@Url.BowerbirdJsView("streamListView.js")"></script>
- <script type="text/javascript" src="@Url.BowerbirdJsView("streamView.js")"></script>
- <script type="text/javascript" src="@Url.BowerbirdJsView("mediaResourceItemView.js")"></script>
---<script type="text/javascript" src="@Url.BowerbirdJsView("avatarMediaResourceView.js")"></script>
- <script type="text/javascript" src="@Url.BowerbirdJsView("editMapView.js")"></script>
- <script type="text/javascript" src="@Url.BowerbirdJsView("editMediaView.js")"></script>
- <script type="text/javascript" src="@Url.BowerbirdJsView("editAvatarView.js")"></script>
-diff --cc Src/Bowerbird.Website/Areas/Members/Views/Shared/_ProjectCreate.cshtml
-index 8284917,8284917..5149602
---- a/Src/Bowerbird.Website/Areas/Members/Views/Shared/_ProjectCreate.cshtml
-+++ b/Src/Bowerbird.Website/Areas/Members/Views/Shared/_ProjectCreate.cshtml
-@@@ -27,19 -27,19 +27,25 @@@
- <input type="text" id="website" name="website" value="{{website}}" />
- </div>
- </div>
--- <fieldset id="avatar-fieldset">
--- <legend>Project Avatar</legend>
--- <p>Drag and drop file into the box below, or choose file from your computer or import from other websites.</p>
-++ <fieldset id="media-resources-fieldset">
-++ <legend>Images, Videos, Audio</legend>
-++ <p>Drag and drop files into the box below, or choose files from your computer or import from other websites.</p>
- <div id="media-uploader">
- <div class="media-resource-items" id="media-resource-items">
--- <div class="media-resource-dropzone"><p>Drop file here</p></div>
-++ <div class="media-resource-dropzone"><p>Drop files here<p></div>
- <div id="media-resource-add-pane">
--- <div id="media-resource-upload-button" class="button media-resource-upload-button">Choose File<input id="fileupload" type="file" name="file"></div>
-++ <div id="media-resource-upload-button" class="button media-resource-upload-button">Choose Files<input id="fileupload" type="file" name="file" multiple></div>
- <input type="button" value="Import From Website" id="media-resource-import-button"/> 
- </div>
- </div>
- </div>
- </fieldset>
-++ <fieldset id="avatar-fieldset">
-++ <legend>Project Avatar</legend>
-++ <div id="avatar-uploader">
-++ 
-++ </div>
-++ </fieldset>
- </fieldset>
- <fieldset>
- <input type="button" value="Save" id="save" />
-diff --cc Src/Bowerbird.Website/Bowerbird.Website.csproj
-index 2934a94,2934a94..f454fea
---- a/Src/Bowerbird.Website/Bowerbird.Website.csproj
-+++ b/Src/Bowerbird.Website/Bowerbird.Website.csproj
-@@@ -207,7 -207,7 +207,6 @@@
- <Content Include="js\bowerbird\appRouter.js" />
- <Content Include="js\bowerbird\views\appView.js" />
- <Content Include="js\bowerbird\views\chatView.js" />
--- <Content Include="js\bowerbird\views\avatarMediaResourceView.js" />
- <Content Include="js\bowerbird\views\editAvatarView.js" />
- <Content Include="js\bowerbird\views\organisationCreateFormView.js" />
- <Content Include="js\bowerbird\views\teamCreateFormView.js" />
-diff --cc Src/Bowerbird.Website/js/bowerbird/models/project.js
-index ab675fd,ab675fd..98535fc
---- a/Src/Bowerbird.Website/js/bowerbird/models/project.js
-+++ b/Src/Bowerbird.Website/js/bowerbird/models/project.js
-@@@ -6,19 -6,19 +6,21 @@@ window.Bowerbird.Models.Project = Backb
- name: '',
- description: '',
- website: '',
--- avatar: null
-++ avatar: ''
- },
- 
- initialize: function (options) {
- _.extend(this, Backbone.Events);
--- this.avatar = new Bowerbird.Models.MediaResource();
-++ //this.avatar = new Bowerbird.Models.MediaResource();
-++ this.avatar = { id: '', url: '', altTag: '' };
- },
- 
- toJSON: function () {
- return {
- name: this.get('name'),
- description: this.get('description'),
--- website: this.get('website')
-++ website: this.get('website'),
-++ avatar: this.get('avatar').id
- };
- },
- 
-diff --cc Src/Bowerbird.Website/js/bowerbird/views/avatarMediaResourceView.js
-index 36cb66e,36cb66e..0000000
-deleted file mode 100644,100644
---- a/Src/Bowerbird.Website/js/bowerbird/views/avatarMediaResourceView.js
-+++ /dev/null
-@@@ -1,45 -1,45 +1,0 @@@
---
---window.Bowerbird.Views.AvatarMediaResourceView = Backbone.View.extend({
--- className: 'avatar-media-resource-uploaded',
---
--- events: {
--- 'click .view-media-resource-button': 'viewMediaResource',
--- 'click .add-caption-button': 'viewMediaResource',
--- 'click .remove-media-resource-button': 'removeMediaResource'
--- },
---
--- initialize: function (options) {
--- _.extend(this, Backbone.Events);
--- _.bindAll(this,
--- 'showTempMedia',
--- 'showUploadedMedia'
--- );
--- this.mediaResource = options.mediaResource;
--- this.parent = options.parent;
--- this.mediaResource.on('change:mediumImageUri', this.showUploadedMedia);
--- },
---
--- render: function () {
--- var avatarUploaded = ich.avataruploaded({ avatar: this.mediaResource.toJSON() });
--- this.$el.append(projectTemplate);
--- window.scrollTo(0, 0);
--- return this;
--- },
---
--- viewMediaResource: function () {
--- alert('Coming soon');
--- },
---
--- removeMediaResource: function () {
--- this.parent.avatar = null;
--- this.remove();
--- },
---
--- showTempMedia: function (img) {
--- this.$el.find('div:first-child img').replaceWith($(img));
--- },
---
--- showUploadedMedia: function (mediaResource) {
--- this.$el.find('div:first-child img').replaceWith($('<img src="' + mediaResource.get('mediumImageUri') + '" alt="" />'));
--- }
---});
-diff --cc Src/Bowerbird.Website/js/bowerbird/views/editAvatarView.js
-index 63f6a4e,63f6a4e..42b3523
---- a/Src/Bowerbird.Website/js/bowerbird/views/editAvatarView.js
-+++ b/Src/Bowerbird.Website/js/bowerbird/views/editAvatarView.js
-@@@ -1,6 -1,6 +1,6 @@@
- 
- window.Bowerbird.Views.EditAvatarView = Backbone.View.extend({
--- id: 'media-resources-fieldset',
-++ id: 'avatar-fieldset',
- 
- initialize: function (options) {
- _.extend(this, Backbone.Events);
-@@@ -10,8 -10,8 +10,8 @@@
- '_onSubmitUpload',
- '_onUploadAdd'
- );
--- this.avatarMediaResourceView = null;
--- this.parent = options.parent;
-++ this.mediaResourceItemViews = [];
-++ this.observation = options.observation;
- this.currentUploadKey = 0;
- },
- 
-@@@ -25,36 -25,36 +25,36 @@@
- dataType: 'json',
- paramName: 'file',
- url: '/members/mediaresource/avatarupload',
--- add: this._onUploadAdd,
-++ add: this._onUploadAd,
- submit: this._onSubmitUpload,
--- done: this._onUploadDone,
--- limitMultiFileUploads: 1
-++ done: this._onUploadDone
- });
- },
- 
- _onUploadAdd: function (e, data) {
- var self = this;
---// $.each(data.files, function (index, file) {
---// if (file != null) {
---// self.currentUploadKey++;
---// var mediaResource = new Bowerbird.Models.MediaResource({ key: self.currentUploadKey });
---// self.parent.set('avatar', mediaResource);
---// self.avatarMediaResourceView = new Bowerbird.Views.AvatarMediaResourceView({ mediaResource: mediaResource, parent: self.parent });
---// $('#media-resource-add-pane').before(mediaResourceItemView.render().el);
---// loadImage(
---// data.files[0],
---// function (img) {
---// if (img instanceof HTMLImageElement) { // FF seems to fire this handler twice, on second time returning error, which we ignore :(
---// avatarMediaResourceView.showTempMedia(img);
---// $('#media-resource-items').animate({ scrollLeft: 100000 });
---// }
---// },
---// {
---// maxHeight: 220
---// }
---// );
---// }
---// });
-++ $.each(data.files, function (index, file) {
-++ if (file != null) {
-++ self.currentUploadKey++;
-++ var mediaResource = new Bowerbird.Models.MediaResource({ key: self.currentUploadKey });
-++ self.observation.addMediaResources.add(mediaResource);
-++ var mediaResourceItemView = new Bowerbird.Views.MediaResourceItemView({ mediaResource: mediaResource });
-++ self.mediaResourceItemViews.push(mediaResourceItemView);
-++ $('#media-resource-add-pane').before(mediaResourceItemView.render().el);
-++ loadImage(
-++ data.files[0],
-++ function (img) {
-++ if (img instanceof HTMLImageElement) { // FF seems to fire this handler twice, on second time returning error, which we ignore :(
-++ mediaResourceItemView.showTempMedia(img);
-++ $('#media-resource-items').animate({ scrollLeft: 100000 });
-++ }
-++ },
-++ {
-++ maxHeight: 220
-++ }
-++ );
-++ }
-++ });
- data.submit();
- },
- 
-@@@ -66,7 -66,7 +66,7 @@@
- // var mediaResource = _.find(this.observation.allMediaResources(), function (item) {
- // return item.get('key') == data.result.key;
- // });
--- this.parent.set('avatar', data.result);
-++ mediaResource.set(data.result);
- //$('#media-resource-items').animate({ scrollLeft: 100000 });
- }
- });
-diff --cc Src/Bowerbird.Website/js/bowerbird/views/editMediaView.js
-index a519b9d,a519b9d..6a98e3e
---- a/Src/Bowerbird.Website/js/bowerbird/views/editMediaView.js
-+++ b/Src/Bowerbird.Website/js/bowerbird/views/editMediaView.js
-@@@ -4,7 -4,7 +4,12 @@@ window.Bowerbird.Views.EditMediaView = 
- 
- initialize: function (options) {
- _.extend(this, Backbone.Events);
--- _.bindAll(this, '_initMediaUploader', '_onUploadDone', '_onSubmitUpload', '_onUploadAdd');
-++ _.bindAll(this,
-++ '_initMediaUploader',
-++ '_onUploadDone',
-++ '_onSubmitUpload',
-++ '_onUploadAdd'
-++ );
- this.mediaResourceItemViews = [];
- this.observation = options.observation;
- this.currentUploadKey = 0;
-diff --cc Src/Bowerbird.Website/js/bowerbird/views/projectCreateFormView.js
-index 6c58d6b,6c58d6b..167156d
---- a/Src/Bowerbird.Website/js/bowerbird/views/projectCreateFormView.js
-+++ b/Src/Bowerbird.Website/js/bowerbird/views/projectCreateFormView.js
-@@@ -14,16 -14,16 +14,31 @@@ window.Bowerbird.Views.ProjectCreateFor
- 
- initialize: function (options) {
- _.extend(this, Backbone.Events);
-++ _.bindAll(this,
-++ 'render',
-++ 'start',
-++ '_cancel',
-++ '_contentChanged',
-++ '_save'
-++// ,
-++// '_initMediaUploader',
-++// '_onUploadAdd',
-++// '_onSubmitUpload',
-++// '_onUploadDone'
-++ );
- this.appView = options.appView;
- this.project = options.project;
--- this.editAvatarView = new Bowerbird.Views.EditAvatarView({ el: $('#media-resources-fieldset'), parent: this.project });
-++ //this.editAvatarView = new Bowerbird.Views.EditAvatarView({ el: $('#avatar-uploader'), project: this.project });
-++ this.editMediaView = new Bowerbird.Views.EditMediaView({ el: $('#media-resources-fieldset'), observation: this.observation });
-++
- },
- 
- render: function () {
--- var projectTemplate = ich.projectcreate({ project: app.get('newProject').toJSON() });
--- //var projectTemplate = ich.projectcreate({});
--- this.$el.append(projectTemplate);
--- window.scrollTo(0, 0);
-++ var projectTemplate = ich.projectcreate({ project: app.get('newProject').toJSON() }).appendTo(this.$el);
-++ // this.$el.append(projectTemplate);
-++ // var avatarUploader = ich.avataruploader();
-++// this.$el.find('#avatar-uploader').append(avatarUploader);
-++ // this._initMediaUploader();
- return this;
- },
- 
-@@@ -50,4 -50,4 +65,46 @@@
- //this.remove();
- //app.appRouter.navigate(app.stream.get('uri'), { trigger: true });
- }
-++// ,
-++
-++// _initMediaUploader: function () {
-++// log('projectCreateFormView._initMediaUploader');
-++
-++// $('#fileupload').fileupload({
-++// dataType: 'json',
-++// paramName: 'file',
-++// url: '/members/mediaresource/avatarupload',
-++// add: this._onUploadAdd,
-++// submit: this._onSubmitUpload,
-++// done: this._onUploadDone,
-++// limitMultiFileUploads: 1
-++// });
-++
-++// log('finish editAvatarView._initMediaUploader');
-++// },
-++
-++// _onUploadAdd: function (e, data) {
-++// log('projectCreateFormView._onUploadAdd');
-++// alert('added');
-++// data.submit();
-++// },
-++
-++// _onSubmitUpload: function (e, data) {
-++// log('projectCreateFormView._onSubmitUpload');
-++
-++// data.formData = { originalFileName: data.files[0].name };
-++// },
-++
-++// _onUploadDone: function (e, data) {
-++// log('projectCreateFormView._onUploadDone');
-++
-++// var uploadedAvatar = new 
-++// {
-++// id: data.id,
-++// url: data.mediumImageUrl,
-++// altTag: ''
-++// };
-++
-++// this.project.set('avatar', uploadedAvatar);
-++// }
- });

0 comments on commit 460f889

Please sign in to comment.
Something went wrong with that request. Please try again.