Sha256: 563799d99a48c69b5e0e220c1a6a6221d40d8e8d0fb0c953593fcb66d01cc65a

Contents?: true

Size: 1.73 KB

Versions: 26

Compression:

Stored size: 1.73 KB

Contents

module Knitkit
  module ErpApp
    module Desktop
      class OnlineDocumentSectionsController < Knitkit::ErpApp::Desktop::AppController
        
        def new
          website = Website.find(params[:website_id])
          online_document_section = OnlineDocumentSection.new(:website_id => website.id, :in_menu => params[:in_menu] == 'yes', :title => params[:title],
                                                              :internal_identifier => params[:internal_identifier])
           
          if online_document_section.save
            if params[:website_section_id]
              parent_website_section = WebsiteSection.find(params[:website_section_id])
              online_document_section.move_to_child_of(parent_website_section)
            end 
            online_document_section.update_path!
            if params[:documenttype] == "Content"
              documented_content = DocumentedContent.create(:title => online_document_section.title, :created_by => current_user, :body_html => online_document_section.title)
              DocumentedItem.create(:documented_content_id => documented_content.id, :online_document_section_id => online_document_section.id)
            end
            
            result = {:success => true, :node => build_section_hash(online_document_section, online_document_section.website),
                      :documented_content => documented_content.content_hash}
          else
            message = "<ul>"
            online_document_section.errors.collect do |e, m|
              message << "<li>#{e} #{m}</li>"
            end
            message << "</ul>"
            result = {:success => false, :message => message}
          end

          render :json => result
        end     
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
knitkit-2.0.6 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb
knitkit-2.0.5 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb
knitkit-2.0.4 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb
knitkit-2.0.3 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb
knitkit-2.0.2 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb
knitkit-2.0.1 app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb