Refactoring: Removed unneeded Network functionality structure.

This commit is contained in:
Thorsten Eckel 2017-09-12 15:07:10 +02:00
parent cb3506da03
commit 5d73e699fe
14 changed files with 19 additions and 523 deletions

View file

@ -1,67 +0,0 @@
class Index extends App.ControllerContent
events:
'click [data-type=network-new]': 'network_new'
'click [data-type=network-edit]': 'network_edit'
'click [data-type=network-destroy]': 'network_destroy'
'click [data-type=network-category-new]': 'network_category_new'
'click [data-type=network-category-edit]': 'network_category_edit'
'click [data-type=network-category-destroy]': 'network_category_destroy'
constructor: ->
super
# set title
@title 'Network'
@render()
@navupdate '#network'
render: ->
networks = App.Network.all()
network_categories = App.NetworkCategory.all()
for network in networks
@log 'notice', network for network in networks
for network_category in network_categories
@log 'notice', network_category
@html App.view('network')(
networks: App.Network.all(),
)
network_new: (e) ->
e.preventDefault()
new App.ControllerGenericNewWindow(
pageData: {
object: 'Network',
},
genericObject: App.Network,
success: =>
@render()
)
network_edit: (e) ->
e.preventDefault()
@id = $(e.target).parents('[data-id]').data('id')
new App.ControllerGenericEditWindow(
id: @id,
pageData: {
object: 'Network',
},
genericObject: App.Network,
success: =>
@render()
)
network_destroy: (e) ->
e.preventDefault()
id = $(e.target).parents('[data-id]').data('id')
item = App.Network.find(id)
item.destroy() if confirm('Sure?')
@render()
App.Config.set( 'network', Index, 'Routes' )
#App.Config.set( 'Network', { prio: 1500, parent: '', name: 'Networking', target: '#network', role: ['Anybody', 'Customer', 'Agent'] }, 'NavBar' ), 'NavBar' )
#App.Config.set( '', { prio: 1600, parent: '', name: 'anybody+agent', target: '#aa', role: ['Anybody', 'Agent'] }
#App.Config.set( '', { prio: 1600, parent: '', name: 'Anybody', target: '#anybody', role: ['Anybody'] }

View file

@ -1,9 +0,0 @@
class App.Network extends App.Model
@configure 'Network', 'name', 'note', 'active', 'updated_at'
@extend Spine.Model.Ajax
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'note', display: 'Note', note: 'Notes are visible to agents only, never to customers.', tag: 'textarea', limit: 250, null: true },
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'active', default: true },
]

View file

@ -1,3 +0,0 @@
class App.NetworkCategory extends App.Model
@configure 'NetworkCategory', 'name', 'network_id', 'network_category_type_id', 'network_privacy_id', 'note', 'allow_comments', 'active', 'updated_at'
@extend Spine.Model.Ajax

View file

@ -1,3 +0,0 @@
class App.NetworkCategoryType extends App.Model
@configure 'NetworkCategoryType', 'name', 'note', 'active', 'updated_at'
@extend Spine.Model.Ajax

View file

@ -1,3 +0,0 @@
class App.NetworkPrivacy extends App.Model
@configure 'NetworkPrivacy', 'name', 'key', 'updated_at'
@extend Spine.Model.Ajax

View file

@ -1,84 +0,0 @@
<div class="page-header">
<div class="page-header-title">
<h1>Networking <small></small></h1>
</div>
</div>
<div class="row">
<div class="">
<% for network in @networks: %>
<div class="row">
<div class="span9">
<h2><%= network.name %> <small><%= network.note %></small></h2> <span data-id="<%= network.id %>"><a data-type="network-edit" href="#">edit</a> | <a data-type="network-destroy" href="#">delete</a> | <a data-type="network-category-new" href="#">new category</a></span>
<div class="row">
<div class="span4">
<h4>Announcements</h4>
<span data-id="<%= network.id %>"><a data-type="network-category-edit" href="#">edit</a> | <a data-type="network-category-destroy" href="#">delete</a></span>
<ul>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
</ul>
</div>
<div class="span4">
<h4>Questions</h4>
<ul>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="span4">
<h4>Ideas</h4>
<ul>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
</ul>
</div>
<div class="span4">
<h4>Bugs</h4>
<ul>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
<li><a href="#">New XXX</a></li>
</ul>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="span3">
<div class="row">
<div class="span3">
<h2>Actions</h2>
<ul>
<li><a data-type="network-new" href="">New Network</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="span3">
<h2>Activity Stream</h2>
<ul>
<li>New XXX</li>
<li>New XXX</li>
<li>New XXX</li>
<li>New XXX</li>
</ul>
</div>
</div>
</div>
</div>

View file

@ -1,87 +0,0 @@
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
class NetworksController < ApplicationController
prepend_before_action :authentication_check
# GET /networks
# GET /networks.json
def index
@networks = Network.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @networks }
end
end
# GET /networks/1
# GET /networks/1.json
def show
@network = Network.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @network }
end
end
# GET /networks/new
# GET /networks/new.json
def new
@network = Network.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @network }
end
end
# GET /networks/1/edit
def edit
@network = Network.find(params[:id])
end
# POST /networks
# POST /networks.json
def create
@network = Network.new(params[:network])
respond_to do |format|
if @network.save
format.html { redirect_to @network, notice: 'Network was successfully created.' }
format.json { render json: @network, status: :created }
else
format.html { render action: 'new' }
format.json { render json: @network.errors, status: :unprocessable_entity }
end
end
end
# PUT /networks/1
# PUT /networks/1.json
def update
@network = Network.find(params[:id])
respond_to do |format|
if @network.update!(params[:network])
format.html { redirect_to @network, notice: 'Network was successfully updated.' }
format.json { render json: @network, status: :ok }
else
format.html { render action: 'edit' }
format.json { render json: @network.errors, status: :unprocessable_entity }
end
end
end
# DELETE /networks/1
# DELETE /networks/1.json
def destroy
@network = Network.find(params[:id])
@network.destroy
respond_to do |format|
format.html { redirect_to networks_url }
format.json { head :ok }
end
end
end

View file

@ -1,14 +0,0 @@
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
def session( collections, assets, _user )
collections[ Network.to_app_model ] = Network.all
collections[ Network::Category.to_app_model ] = Network::Category.all
collections[ Network::Category::Type.to_app_model ] = Network::Category::Type.all
collections[ Network::Privacy.to_app_model ] = Network::Privacy.all
[collections, assets]
end
module_function :session
end

View file

@ -1,33 +0,0 @@
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
class Network < ApplicationModel
# belongs_to :group
# belongs_to :state, :class_name => 'Ticket::State'
# belongs_to :priority, :class_name => 'Ticket::Priority'
class Category < ApplicationModel
self.table_name = 'network_categories'
class Type < ApplicationModel
end
class Subscription < ApplicationModel
end
end
class Item < ApplicationModel
class Comment < ApplicationModel
end
class Plus < ApplicationModel
self.table_name = 'network_item_plus'
end
class Subscription < ApplicationModel
end
end
class Privacy < ApplicationModel
self.table_name = 'network_privacies'
end
end

View file

@ -1,11 +0,0 @@
Zammad::Application.routes.draw do
api_path = Rails.configuration.api_path
# networkss
match api_path + '/networks', to: 'networks#index', via: :get
match api_path + '/networks/:id', to: 'networks#show', via: :get
match api_path + '/networks', to: 'networks#create', via: :post
match api_path + '/networks/:id', to: 'networks#update', via: :put
match api_path + '/networks/:id', to: 'networks#destroy', via: :delete
end

View file

@ -1,108 +0,0 @@
class CreateNetwork < ActiveRecord::Migration[4.2]
def up
create_table :networks do |t|
t.column :name, :string, limit: 100, null: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :networks, [:name], unique: true
create_table :network_category_types do |t|
t.column :name, :string, limit: 100, null: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_category_types, [:name], unique: true
create_table :network_privacies do |t|
t.column :name, :string, limit: 100, null: false
t.column :key, :string, limit: 250, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_privacies, [:name], unique: true
create_table :network_categories do |t|
t.references :network_category_type, null: false
t.references :network_privacy, null: false
t.references :network, null: false
t.column :name, :string, limit: 200, null: false
t.column :note, :string, limit: 250, null: true
t.column :allow_comments, :boolean, null: false, default: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_categories, [:network_id]
create_table :network_categories_moderator_users, id: false do |t|
t.integer :user_id
t.integer :network_category_id
end
create_table :network_items do |t|
t.references :network_category, null: false
t.column :title, :string, limit: 200, null: false
t.column :body, :string, limit: 20_000, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps null: false
end
add_index :network_items, [:network_category_id]
create_table :network_item_comments do |t|
t.references :network_item, null: false
t.column :body, :string, limit: 20_000, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_item_comments, [:network_item_id]
create_table :network_item_plus do |t|
t.references :network_item, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_item_plus, [:network_item_id, :created_by_id], unique: true
create_table :network_category_subscriptions do |t|
t.references :network_categories, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_category_subscriptions, [:network_categories_id, :created_by_id], unique: true, name: 'index_network_category_subscriptions_on_network_c_i_and_c'
create_table :network_item_subscriptions do |t|
t.references :network_item, null: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :network_item_subscriptions, [:network_item_id, :created_by_id], unique: true, name: 'index_network_item_subscriptions_on_item_id_and_created_by_id'
end
def down
drop_table :network_item_subscriptions
drop_table :network_category_subscriptions
drop_table :network_categories_moderator_users
drop_table :network_item_plus
drop_table :network_item_comments
drop_table :network_items
drop_table :network_categories
drop_table :network_privacies
drop_table :network_category_types
drop_table :networks
end
end

View file

@ -0,0 +1,18 @@
class RemoveNetwork < ActiveRecord::Migration
# rewinds db/migrate/20120101000020_create_network.rb
def change
return if !ActiveRecord::Base.connection.table_exists? 'networks'
drop_table :networks
drop_table :network_category_types
drop_table :network_privacies
drop_table :network_categories
drop_table :network_categories_moderator_users
drop_table :network_items
drop_table :network_item_comments
drop_table :network_item_plus
drop_table :network_category_subscriptions
drop_table :network_item_subscriptions
end
end

View file

@ -13,7 +13,7 @@ Cache.clear
# this is the __ordered__ list of seed files
# extend only if needed - try to add your changes
# to the matching one of the existing files
seeds = %w(settings user_nr_1 signatures roles permissions groups links ticket_state_types ticket_states ticket_priorities ticket_article_types ticket_article_senders macros community_user_resources overviews channels report_profiles chats networks object_manager_attributes schedulers triggers karma_activities)
seeds = %w(settings user_nr_1 signatures roles permissions groups links ticket_state_types ticket_states ticket_priorities ticket_article_types ticket_article_senders macros community_user_resources overviews channels report_profiles chats object_manager_attributes schedulers triggers karma_activities)
# loop and require all seedfiles
# files will get executed automatically

View file

@ -1,100 +0,0 @@
network = Network.create_if_not_exists(
id: 1,
name: 'base',
)
Network::Category::Type.create_if_not_exists(
id: 1,
name: 'Announcement',
)
Network::Category::Type.create_if_not_exists(
id: 2,
name: 'Idea',
)
Network::Category::Type.create_if_not_exists(
id: 3,
name: 'Question',
)
Network::Category::Type.create_if_not_exists(
id: 4,
name: 'Bug Report',
)
Network::Privacy.create_if_not_exists(
id: 1,
name: 'logged in',
key: 'loggedIn',
)
Network::Privacy.create_if_not_exists(
id: 2,
name: 'logged in and moderator',
key: 'loggedInModerator',
)
Network::Category.create_if_not_exists(
id: 1,
name: 'Announcements',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Announcement').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in and moderator').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 2,
name: 'Questions',
network_id: network.id,
allow_comments: true,
network_category_type_id: Network::Category::Type.find_by(name: 'Question').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
)
Network::Category.create_if_not_exists(
id: 3,
name: 'Ideas',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Idea').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 4,
name: 'Bug Reports',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Bug Report').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
item = Network::Item.create(
title: 'Example Announcement',
body: 'Some announcement....',
network_category_id: Network::Category.find_by(name: 'Announcements').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Question?',
body: 'Some questions....',
network_category_id: Network::Category.find_by(name: 'Questions').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Idea',
body: 'Some idea....',
network_category_id: Network::Category.find_by(name: 'Ideas').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Bug Report',
body: 'Some bug....',
network_category_id: Network::Category.find_by(name: 'Bug Reports').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)